constructor() { const api = new MiscApi(); this.router = api.apiRouter(); this.router.get('/v1/sitemap', api.sitemap.bind(api)); this.router.get('/v1/ping', api.ping.bind(api)); this.router.get('/v1/plans', api.plans.bind(api)); this.router.get('/v1/roles', api.auth(api.roles.bind(api), 'roles', 'list', [ Scope.ALL ])); this.router.get('/v1/ipdb/:id', api.auth(api.ipdbDetails.bind(api), 'ipdb', 'view', [ Scope.ALL ])); this.router.delete('/v1/cache', api.auth(api.invalidateCache.bind(api), 'cache', 'delete', [ Scope.ALL ])); if (process.env.ENABLE_KILL_SWITCH) { this.router.post('/v1/kill', api.kill.bind(api)); } this.router.get('index', '/v1', api.index.bind(api)); this.router.redirect('/', 'index'); apiCache.enable(this.router, '/v1/sitemap', { entities: [], listModels: ['game', 'release'] }); }
this.set('X-Response-Time', ms + 'ms'); }); // logger app.use(function *(next){ const start = new Date().getTime(); yield next; const ms = new Date().getTime() - start; console.log('%s %s - %s', this.method, this.url, ms); }); // Redirect redirect_router.redirect('/', '/static/main.html'); app.use(redirect_router.routes()); app.use(redirect_router.allowedMethods()); // static app.use(mount('/static', serve('../frontend/build'))); // responses under /api router.get('/hello', function *(next) { this.body = 'hello'; });