This commit is contained in:
syuilo 2018-04-13 06:06:18 +09:00
parent a3bd4ba426
commit 3368fe8552
20 changed files with 582 additions and 609 deletions

View file

@ -1,24 +1,21 @@
/**
* Docs Server
* Docs
*/
import * as path from 'path';
import * as express from 'express';
import * as Router from 'koa-router';
import * as send from 'koa-send';
const docs = path.resolve(`${__dirname}/../../client/docs/`);
/**
* Init app
*/
const app = express();
app.disable('x-powered-by');
const router = new Router();
app.use('/assets', express.static(`${docs}/assets`));
router.get('/assets', async ctx => {
await send(ctx, `${docs}/assets`);
});
/**
* Routing
*/
app.get(/^\/([a-z_\-\/]+?)$/, (req, res) =>
res.sendFile(`${docs}/${req.params[0]}.html`));
router.get(/^\/([a-z_\-\/]+?)$/, async ctx => {
await send(ctx, `${docs}/${ctx.params[0]}.html`);
});
module.exports = app;
module.exports = router;