@eside/leopold
v1.0.5
Published
<h1 align="center">leopold-base</h1>
Readme
当前集成插件
- [x] Cors跨域请求处理(简易版)
- [x] 静态文件(基于koa-mount,koa-static,并提供有限的配置自定义)
- [x] Log4j日志系统(简易版)
- [x] 请求体处理(基于koa-body,并提供有限的配置自定义)
- [x] 页面压缩
- [x] 模板引擎(基于ejs)
- [x] 动态路由自动注册(使用path-match定制)
提供的工具
- [x] 统一返回结果处理
- [x] 定时任务设置
- [x] Mysql的集成使用
配置文件范例
- config.json
{
"port": 8360,
"DB": {
"mysql": {
"host": "localhost",
"user": "mp_starter",
"password": "mp_starter",
"database": "mp_starter",
"waitForConnections": true,
"connectionLimit": 5,
"maxIdle": 0,
"idleTimeout": 60000,
"queueLimit": 0,
"enableKeepAlive": true,
"keepAliveInitialDelay": 1000
},
"sqlite": {
"database": "./test.db"
}
},
"Model": [
{ "type": "mysql", "dir": "/model/mysql-model" },
{ "type": "sqlite", "dir": "/model/sqlite-model" }
],
"Cors": {
"/": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Expose-Headers": "*",
"Access-Control-Max-Age": 60,
"Access-Control-Allow-Methods": "PUT, POST, GET, DELETE, OPTIONS"
}
},
"BodyParser": {
"/": {
"multipart": true,
"formidable": {
"maxFileSize": 209715200,
"keepExtensions": true
}
}
},
"Compress": {
"/": {
"threshold": 2048,
"filter": "json|text"
}
},
"TemplateHandler": {
"/server/template": {
"extension": "ejs"
}
},
"Assets": {
"/static": {
"index": "index.html",
"hidden": false,
"defer": true
}
},
"DynamicRoutes": [{ "match": "/api/", "dir": "/server/api" }]
}程序使用
// main.js
// 默认 localhost:8360
const App = require('@eside/leopold')
const app = new App()
app.use(router.routes(), router.allowedMethods())
app.listen()版本记录
- 1.0.0
- 待补充
