refactor: logo

This commit is contained in:
xiaojunnuo
2021-02-09 15:42:10 +08:00
parent b4560d6370
commit f96697f619
12 changed files with 189 additions and 155 deletions

View File

@@ -7,6 +7,7 @@ import Static from 'koa-static'
import fs from 'fs'
import _ from 'lodash-es'
import './install.js'
import pathUtil from './utils/util.path.js'
const app = new Koa()
// error handler
@@ -19,7 +20,10 @@ app.use(bodyparser({
app.use(json())
app.use(logger())
app.use(Static(new URL('public', import.meta.url).pathname))
const staticPlugin = Static(pathUtil.join('public'), {
maxage: 30 * 24 * 60 * 3600
})
app.use(staticPlugin)
// logger
app.use(async (ctx, next) => {
@@ -29,8 +33,6 @@ app.use(async (ctx, next) => {
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`)
})
console.log('url', import.meta.url)
// routes
const files = fs.readdirSync(new URL('controllers/', import.meta.url))
// 过滤出.js文件: