/** * Created by Tony on 2020/3/10. */ const express = require('express'); const app = express(); const _rootDir = __dirname; app.locals.rootDir = _rootDir; app.use(express.static(_rootDir)); // app.set('views', path.join(_rootDir, 'web')); // app.engine('.html', require('ejs').__express); // app.set('view engine', 'html'); let bodyParser = require('body-parser'); app.use(bodyParser.json()); // app.use(bodyParser.urlencoded({limit: '100mb', extended: false})); // app.use(bodyParser.json({limit: '100mb'})); // 登录状态全局判断 //加载路由文件 // fileUtils.getGlobbedFiles('./modules/**/routes/*.js').forEach(function(modelPath) { // if(modelPath.indexOf("import/routes")==-1) require(path.resolve(modelPath))(app);//排除掉导出导入服务 // }); app.all("*", function(request, response, next) { response.header("Access-Control-Allow-Origin", "*"); // 设置跨域的域名,* 代表允许任意域名跨域 response.header("Access-Control-Allow-Headers", "X-Requested-With"); response.header( "Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS" ); response.header("X-Powered-By", " 3.2.1"); response.header("Content-Type", "application/json;charset=utf-8"); next(); }); app.use(express.static(_rootDir+"/web")); app.use(express.static(_rootDir+"/lib")); // let Router = require("./router"); // app.use("/export",Router); require("./router")(app); //----------------- app.use(function(req, res, next) { res.status(404).send('404 Error'); }); app.use(function(err, req, res, next) { console.error(err.stack); res.status(500).send('500 Error'); }); //设置外增的Date对象Format函数 //备注: 经过测试nodejs 8.9.3版本不支持eval的方式修改prototype,为兼容考虑,把方法调整到stringUtil文件里 require('./public/stringUtil').setupDateFormat(); app.listen(3036, function(){ console.log('server started!'); }); //设置schedule job //1. 报表临时文件 // rptCronJob.createJob(null, _rootDir + "/tmp"); //2. 其他(待补充)...