再次复习koa-static 我发现改版了,一些代码改了
const Koa = require('koa')
const static = require('koa-static')
const router = require('koa-router')()
const server = new Koa();
router.get('/', async ctx => {
ctx.body = "//html"
});
router.all(/((\.jpg)|(\.png)|(\.gif))$/i, static('./static', {
maxage: 5 * 86400 * 1000
}));
router.all(/((\.js)|(\.jsx))$/i, static('./static', {
maxage: 2 * 86400 * 1000
}));
router.all(/(\.css)$/i, static('./static', {
maxage: 3 * 86400 * 1000
}));
router.all(/((\.html)|(\.htm))$/i, static('./static', {
maxage: 2 * 86400 * 1000
}));
router.all('*', static('./static', {
maxage: 3 * 86400 * 1000
}));
server.use(router.routes())
// server.use(static('./static', {
// maxage: 1 * 86400 * 1000
// }))
server.listen(3000)const