2017-12-16 09:41:22 -07:00
|
|
|
/**
|
2018-04-12 15:06:18 -06:00
|
|
|
* Docs
|
2017-12-16 09:41:22 -07:00
|
|
|
*/
|
|
|
|
|
2018-04-12 21:05:24 -06:00
|
|
|
import ms = require('ms');
|
2018-04-12 15:06:18 -06:00
|
|
|
import * as Router from 'koa-router';
|
|
|
|
import * as send from 'koa-send';
|
2017-12-16 09:41:22 -07:00
|
|
|
|
2018-04-12 21:05:24 -06:00
|
|
|
const docs = `${__dirname}/../../client/docs/`;
|
2018-03-29 05:50:45 -06:00
|
|
|
|
2018-04-12 15:06:18 -06:00
|
|
|
const router = new Router();
|
2017-12-16 09:41:22 -07:00
|
|
|
|
2018-04-12 21:05:24 -06:00
|
|
|
router.get('/assets/*', async ctx => {
|
2018-04-12 21:08:56 -06:00
|
|
|
await send(ctx, ctx.params[0], {
|
|
|
|
root: docs + '/assets/',
|
2018-04-12 21:05:24 -06:00
|
|
|
maxage: ms('7 days'),
|
|
|
|
immutable: true
|
|
|
|
});
|
2018-04-12 15:06:18 -06:00
|
|
|
});
|
2017-12-16 09:41:22 -07:00
|
|
|
|
2018-04-12 21:05:24 -06:00
|
|
|
router.get('*', async ctx => {
|
|
|
|
await send(ctx, `${ctx.params[0]}.html`, {
|
|
|
|
root: docs
|
|
|
|
});
|
2018-04-12 15:06:18 -06:00
|
|
|
});
|
2017-12-16 09:41:22 -07:00
|
|
|
|
2018-04-12 21:05:24 -06:00
|
|
|
export default router;
|