feat: Serve static files under ./static
1 file changed, 11 insertions(+), 0 deletions(-)
changed files
M src/index.js → src/index.js
@@ -3,6 +3,8 @@ const Koa = require('koa') const app = new Koa() +const send = require('koa-send') + const config = require('./modules/config.js') const PORT = process.env.PORT || config.server.port@@ -58,6 +60,15 @@ }) } app.use(router.routes()).use(router.allowedMethods()) + +const prefix = /^\/static\// +app.use(async function (ctx) { + if (prefix.test(ctx.path)) { + await send(ctx, ctx.path.replace(prefix, ''), { + root: './static' + }) + } +}) module.exports = app