-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
43 lines (38 loc) · 1.53 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const express = require('express');
const logger = require('logger');
const auth = require('auth');
const utils = require('utils');
const nn_error = require('nn_error');
const fs = require('fs');
const path = require('path');
const route = express.Router();
const xmlbuilder = require("xmlbuilder")
route.use((req, res, next) => {
auth.checkAuth(req, res, next);
});
route.get("/agreements/Nintendo-Network-EULA/:region/@latest", (req, res) => {
const region = req.params['region']; // TODO: create other region specific agreements
let agreements = path.resolve(__dirname, "agreements");
const agreementRegion = path.join(agreements, `${region}.xml`);
res.setHeader("Content-Type", "application/xml");
if (fs.existsSync(agreementRegion)) {
res.sendFile(agreementRegion);
} else {
logger.error(`[content]: File ${agreementRegion} for regional agreements cannot be found.`);
res.status(404).send(utils.generateNotFound());
}
});
route.get("/time_zones/:region/:lang", (req, res) => {
const region = req.params['region'];
const lang = req.params['lang'];
let time_zones = path.resolve(__dirname, "time_zones");
const timezoneList = path.join(time_zones, region, `${lang}.xml`);
res.setHeader("Content-Type", "application/xml");
if (fs.existsSync(timezoneList)) {
res.sendFile(timezoneList);
} else {
logger.error(`[content]: File ${tz_thingy} for timezones cannot be found.`);
res.status(404).send(utils.generateNotFound());
}
});
module.exports = route;