@@ -1,23 +1,18 @@ | |||||
{ | { | ||||
"name": "ruoyi", | "name": "ruoyi", | ||||
"version": "3.8.6", | "version": "3.8.6", | ||||
"description": "两制一化", | |||||
"author": "融信", | |||||
"description": "文件传输", | |||||
"author": "农燊", | |||||
"license": "MIT", | "license": "MIT", | ||||
"scripts": { | "scripts": { | ||||
"serve": "vue-cli-service serve", | "serve": "vue-cli-service serve", | ||||
"install": "npm update && npm rebuild", | "install": "npm update && npm rebuild", | ||||
"build": "vue-cli-service build", | "build": "vue-cli-service build", | ||||
"start": "npm run start:local", | "start": "npm run start:local", | ||||
"start:local": "DEBUG=* NODE_ENV=local-dev node --abort-on-uncaught-exception start.js --log-level=debug --mode=local-dev", | |||||
"build:dev": "npm run build", | "build:dev": "npm run build", | ||||
"start:dev": "DEBUG=* NODE_ENV=development node --abort-on-uncaught-exception start.js --log-level=debug --mode=development", | |||||
"build:test": "npm run build", | "build:test": "npm run build", | ||||
"start:test": "DEBUG=* NODE_ENV=test node --abort-on-uncaught-exception start.js --log-level=debug --mode=test", | |||||
"build:stage": "npm run build", | "build:stage": "npm run build", | ||||
"start:stage": "DEBUG=rongxin* NODE_ENV=stage node --abort-on-uncaught-exception start.js --log-level=debug --mode=stage", | |||||
"build:prod": "npm run build", | "build:prod": "npm run build", | ||||
"start:prod": "DEBUG=rongxin* NODE_ENV=production node --abort-on-uncaught-exception start.js --log-level=debug --mode=production", | |||||
"preview": "node build/index.js --preview", | "preview": "node build/index.js --preview", | ||||
"lint": "eslint --ext .js,.vue src" | "lint": "eslint --ext .js,.vue src" | ||||
}, | }, | ||||
@@ -59,8 +54,6 @@ | |||||
"js-beautify": "1.13.0", | "js-beautify": "1.13.0", | ||||
"js-cookie": "3.0.1", | "js-cookie": "3.0.1", | ||||
"jsencrypt": "3.0.0-rc.1", | "jsencrypt": "3.0.0-rc.1", | ||||
"nongfu.merchant.bootstrap": "git+ssh://git@gitlab.cacfintech.com:racoon/nongfu.merchant.bootstrap.git#stable", | |||||
"nongfu.merchant.policyrouter": "git+ssh://git@gitlab.cacfintech.com:racoon/nongfu.merchant.policyrouter.git#stable", | |||||
"nprogress": "0.2.0", | "nprogress": "0.2.0", | ||||
"quill": "1.3.7", | "quill": "1.3.7", | ||||
"request": "^2.88.2", | "request": "^2.88.2", | ||||
@@ -1,65 +0,0 @@ | |||||
'use strict' | |||||
/** | |||||
* proxy api http request to rongxin.gov.rgvn.api service | |||||
*/ | |||||
const proxy = require('http-proxy-middleware') | |||||
const config = require('config') | |||||
const logFactory = require('../utils/logFactory') | |||||
const logUtil = require('../utils/logUtil') | |||||
const debug = logFactory(logUtil())('rongxin.gov.rgvn.dashboard.tiandeng:routes:apiProxy') | |||||
class ApiProxy { | |||||
constructor(policyRouter) { | |||||
this._policyRouter = policyRouter | |||||
} | |||||
onProxyReq (proxyReq, req, res, options) { | |||||
const method = 'proxyReq' | |||||
debug(method, '[Proxy-Enter]', req.path) | |||||
if (req.path.startsWith('/api')) { | |||||
proxyReq.path = proxyReq.path.substring(4) | |||||
debug(method, 'proxyReq.path: ', proxyReq.path, req.path) | |||||
} | |||||
} | |||||
onProxyRes (proxyRes, req, res) { | |||||
let method = "onProxyRes" | |||||
debug('[Proxy-Exit]', req.path) | |||||
debug('[onProxyRes] ', 'req.path = ', req.path, 'req.method = ', req.method) | |||||
} | |||||
onError (err, req, res) { | |||||
let method = 'onError' | |||||
debug.error(method, err) | |||||
} | |||||
init () { | |||||
const self = this | |||||
const govRgvnApiServiceUrl = `${config.get('rongxin_gov_rgvn_api_service').host}:${config.get('rongxin_gov_rgvn_api_service').port}`; | |||||
const proxyInst = proxy({ | |||||
target: govRgvnApiServiceUrl, | |||||
router: { | |||||
}, | |||||
changeOrigin: true, | |||||
logLevel: 'debug', | |||||
logProvider: () => debug, | |||||
onProxyRes: self.onProxyRes.bind(self), | |||||
onProxyReq: self.onProxyReq.bind(self), | |||||
onError: self.onError.bind(self) | |||||
}) | |||||
self._policyRouter.use('/api', proxyInst, { | |||||
name: 'apiProxy.proxyInst' | |||||
}); | |||||
debug.info(`api proxy, api service uri: ${govRgvnApiServiceUrl}`) | |||||
return self | |||||
} | |||||
} | |||||
module.exports = ApiProxy |
@@ -1,36 +0,0 @@ | |||||
/** | |||||
* Http compression router | |||||
* @author tala | |||||
* 2018-05-23 | |||||
*/ | |||||
'use strict' | |||||
const compression = require('compression') | |||||
class HttpCompression { | |||||
constructor(policyRouter) { | |||||
this._policyRouter = policyRouter | |||||
} | |||||
init() { | |||||
let self = this | |||||
// compression | |||||
self._policyRouter.use('/', compression({ | |||||
filter: function(req, res) { | |||||
if (req.headers['x-no-compression']) { | |||||
// don't compress responses with this request header | |||||
return false; | |||||
} | |||||
// fallback to standard filter function | |||||
return compression.filter(req, res); | |||||
} | |||||
}), { | |||||
name: 'httpCompression', | |||||
}) | |||||
return self | |||||
} | |||||
} | |||||
module.exports = HttpCompression |
@@ -1,36 +0,0 @@ | |||||
/** | |||||
* routes | |||||
* @author eriksen, tala | |||||
*/ | |||||
'use strict' | |||||
const PolicyRouter = require('nongfu.merchant.policyrouter').PolicyRouter; | |||||
const express = require('express') | |||||
let router = express.Router() | |||||
let policyRouter = new PolicyRouter(router) | |||||
let HealthChecker = require('nongfu.merchant.policyrouter').HealthChecker; | |||||
//========================= | |||||
// HttpCompression Router | |||||
//========================= | |||||
let HttpCompression = require('./compression'); | |||||
let httpCompression = new HttpCompression(policyRouter); | |||||
httpCompression.init(); | |||||
//========================= | |||||
// API Proxy Router | |||||
//========================= | |||||
let ApiProxy = require('./apiProxy'); | |||||
let apiProxy = new ApiProxy(policyRouter); | |||||
apiProxy.init(); | |||||
//========================= | |||||
// Static Resource Router | |||||
//========================= | |||||
let StaticResourceProvider = require('./staticResourceProvider'); | |||||
let staticResourceProvider = new StaticResourceProvider(policyRouter); | |||||
staticResourceProvider.init(); | |||||
module.exports = router; |
@@ -1,34 +0,0 @@ | |||||
/** | |||||
* static resource provider router | |||||
* @author tala | |||||
*/ | |||||
'use strict' | |||||
const express = require('express'); | |||||
const path = require('path'); | |||||
class StaticResourceProvider { | |||||
constructor(policyRouter) { | |||||
this._policyRouter = policyRouter | |||||
} | |||||
static get ONE_YEAR() { | |||||
return 365 * 24 * 60 * 60 * 1000; | |||||
} | |||||
init() { | |||||
let self = this | |||||
self._policyRouter.use('/', express.static(path.join(__dirname, '../dist'), { | |||||
maxAge: StaticResourceProvider.ONE_YEAR | |||||
}), { | |||||
name: 'static.dist' | |||||
}); | |||||
return self | |||||
} | |||||
} | |||||
module.exports = StaticResourceProvider |
@@ -1,55 +0,0 @@ | |||||
/** | |||||
* rongxin.gov.rgvn.dashboard.tiandeng | |||||
*/ | |||||
'use strict' | |||||
const logFactory = require('./utils/logFactory') | |||||
const logUtil = require('./utils/logUtil') | |||||
const debug = logFactory(logUtil())('rongxin.gov.rgvn.dashboard.tiandeng') | |||||
const express = require('express') | |||||
const http = require('http') | |||||
const config = require('config') | |||||
const env = require('./services/env') | |||||
const program = require('commander') | |||||
//==================== | |||||
// program parser | |||||
// ==================== | |||||
program | |||||
.version('1.0.0') | |||||
.usage('[options] ') | |||||
.option('-h, --hostname [hostname]', 'Hostname or IP address for the service to bind, if not presented, use the one specfied in conf file') | |||||
.option('-p, --port [port]', 'The service listening port, if not presented, use the one specified in conf file') | |||||
.option('-l, --log-level [log-level]', 'The service log-level') | |||||
.option('-m, --mode [mode]', 'The service process mode, production, stage or test') | |||||
.parse(process.argv) | |||||
let transportConf = { | |||||
host: program.hostname, | |||||
port: program.port | |||||
} | |||||
const bootstrap = require('nongfu.merchant.bootstrap') | |||||
const app = express() | |||||
env.setServerMode(app.get('env')) | |||||
const router = require('./routes') | |||||
app.use('/', router) | |||||
bootstrap.init((error, result) => { | |||||
if (error) | |||||
process.exit(1) | |||||
let hostInEnv = process.env.NODE_HOSTNAME | |||||
let portInEnv = process.env.NODE_PORT | |||||
let host = hostInEnv || transportConf.host || config.get('server').host | |||||
let port = portInEnv || transportConf.port || config.get('server').port | |||||
let server = http.createServer(app) | |||||
server.listen(port, host) | |||||
debug.info(`Server start up on listening [host:${host}, port:${port}]`) | |||||
}) |