1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- const Koa = require('koa');
- const bodyParser = require('koa-bodyparser');
- const session = require('koa-session-minimal');
- const MysqlSession = require('koa-mysql-session');
- const static = require('koa-static');
- const path = require('path');
- const sys = require('./config/sys_test.json');
- const router = require('./router');
- const app = new Koa();
- console.log(sys)
- const store = new MysqlSession({
- connectTimeout : 60* 60 * 60 * 1000,
- host: sys.session.host,
- user: sys.session.user,
- password: sys.session.pwd,
- database: sys.session.db
- });
- const cookie = {
- maxAge: sys.session.max_age,
- path: sys.session.path,
- domain: sys.session.domain,
- httpOnly: sys.session.http_only
- }
- app.use(bodyParser({
- "formLimit": "50mb",
- "jsonLimit": "50mb",
- "textLimit": "50mb"
- }));
- app.use(session({
- key: sys.session.key,
- store: store,
- cookie: cookie
- }));
- app.use(router.routes());
- app.use(router.allowedMethods());
- app.use(static(path.join(__dirname, sys.static_dir), {handle: true}));
- app.listen(sys.port, () => {
- console.log(`${sys.pro_name} is starting at port ${sys.port}`);
- });
|