当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.ts 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
Gj 提交于 2017-10-12 12:43 . gjwork
import * as fs from 'fs';
import * as Koa from 'koa';
import env from './config/env';
import { dingConfig } from './node_modules/dingtalk-app';
import pc_AssignmentManageService from './service/Pc_AssignmentManageService';
import mob_Assignment from "./service/Mob_AssignmentService";
const app = new Koa();
const views = require('koa-views');
const json = require('koa-json');
const onerror = require('koa-onerror');
const bodyparser = require('koa-bodyparser')();
const logger = require('koa-logger');
const bodyParser = require('koa-bodyparser');
const session = require('koa-session');
const convert = require('koa-convert');
const serve = require('koa-static');
let log4js = require('koa-log4');
//视图初始化
// pc_AssignmentManageService.initView();
//此条作废
// mob_Assignment.initComeTrue();
onerror(app);
// middlewares
app.use(bodyparser);
app.use(json());
app.use(logger());
app.use(require('koa-static')(__dirname + '/public'));
//public/images/xxxxxx
app.use(views(__dirname + '/views', {
extension: 'pug'
}));
// logger
app.use(logger());
app.use(bodyParser());
app.keys = ['some secret hurr'];
app.use(convert(session(app)));
app.use(serve(__dirname + '/public'));
dingConfig.init(app, env as any, [/^\/api\/auth\/*/, /^\/api\/*/])
//加载路由
let routers_path = __dirname + '/routes/';
let routers = fs.readdirSync(routers_path)
routers.map(file => {
let mpath = "./routes/";
let route = require(mpath + file.substring(0, file.lastIndexOf('.')));
app.use(route.default.routes())
})
export default app;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化