1234567891011121314151617181920212223242526272829303132 |
- const Koa = require('koa');
- const bodyParser = require('koa-bodyparser');
- const session = require('koa-session-minimal');
- const static = require('koa-static');
- const path = require('path');
- const sys = require('./config/sys.json');
- const router = require('./router');
- const app = new Koa();
- const cookie = {
- maxAge: sys.session.max_age,
- path: sys.session.path,
- domain: sys.session.domain,
- httpOnly: sys.session.http_only
- }
- app.use(bodyParser({
- formLimit: '1000000kb',
- jsonLimit: '1000000kb'
- }));
- app.use(session({
- key: sys.session.key,
- 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}`);
- });
|