wip
This commit is contained in:
parent
a3bd4ba426
commit
3368fe8552
20 changed files with 582 additions and 609 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue