From abe8127840c2ec25b6a27d0c217aa50ef44bd57d Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 13 Feb 2017 12:59:36 +0900 Subject: [PATCH] Refactor --- src/web/about/index.ts | 18 ++++++++++++++++++ src/web/server.ts | 14 +------------- 2 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 src/web/about/index.ts diff --git a/src/web/about/index.ts b/src/web/about/index.ts new file mode 100644 index 000000000..18d259bcc --- /dev/null +++ b/src/web/about/index.ts @@ -0,0 +1,18 @@ +import * as express from 'express'; +import ms = require('ms'); + +const router = express.Router(); + +router.use('/@/about/resources', express.static(`${__dirname}/resources`, { + maxAge: ms('7 days') +})); + +router.get('/@/about/', (req, res) => { + res.sendFile(`${__dirname}/pages/index.html`); +}); + +router.get('/@/about/:page(*)', (req, res) => { + res.sendFile(`${__dirname}/pages/${req.params.page}.html`); +}); + +module.exports = router; diff --git a/src/web/server.ts b/src/web/server.ts index 050a54240..df84facab 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -62,19 +62,7 @@ app.use(subdomain({ /** * Routing */ - -app.use('/@/about/resources', express.static(`${__dirname}/about/resources`, { - maxAge: ms('7 days') -})); - -app.get('/@/about/', (req, res) => { - res.sendFile(`${__dirname}/about/pages/index.html`); -}); - -app.get('/@/about/:page(*)', (req, res) => { - res.sendFile(`${__dirname}/about/pages/${req.params.page}.html`); -}); - +app.use(require('./about')); // about docs app.get('/@/auth/*', serveApp('auth')); // authorize form app.get('/@/dev/*', serveApp('dev')); // developer center app.get('*', serveApp('client')); // client