first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import koa from "koa";
import stati from "koa-static";
import path from "path";
import views from "koa-views";
/**
* 配置所有koa2的中间件
*/
export class init {
protected koa2:any = new koa();
private PluginsArray: Function[];
constructor () {
this.initPlugins();
}
private initPlugins(): any {
this.PluginsArray = [
views(path.join( __dirname, "../resource/view"),{
map: {
jade: 'jade'
},
extension: 'jade'
}),
stati(path.join( __dirname, "../resource/static") ,{
maxage: 3000
})
];
try {
this.PluginsArray.forEach( v => this.koa2.use(v));
} catch (e) {
throw new Error(`配置插件出错:${e.message}`)
}
}
}