@gingkoo/base-server 0.0.1-alpha.9 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +5 -0
- package/backend/router.js +2 -0
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -15,6 +15,7 @@ const router = require('./backend/router');
|
|
|
15
15
|
class App {
|
|
16
16
|
/**
|
|
17
17
|
* @param {string} optinos.timeout 超时时间 默认 30s
|
|
18
|
+
* @param {(app: any, express: any) => void} optinos.middleware 注册中间件
|
|
18
19
|
* @param {(app: any, express: any) => void} optinos.beforeRoutes 在前面注册路由
|
|
19
20
|
* @param {(app: any, express: any) => void} optinos.afterRoutes 在后面注册路由
|
|
20
21
|
*/
|
|
@@ -63,6 +64,10 @@ class App {
|
|
|
63
64
|
this.app.use((req, res, next) => {
|
|
64
65
|
if (!req.timedout) next();
|
|
65
66
|
});
|
|
67
|
+
|
|
68
|
+
if (this.options.middleware) {
|
|
69
|
+
this.options.middleware(this.app, express);
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
routes() {
|
package/backend/router.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const express = require('express');
|
|
4
4
|
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
5
|
+
const { applog } = require('./common/logger');
|
|
5
6
|
const jwt = require('./utils/jwt');
|
|
6
7
|
const config = require('./config/index');
|
|
7
8
|
const mapping = require('./common/mapping');
|
|
@@ -19,6 +20,7 @@ router.get('/(:module/)?mapping', async (req, res) => {
|
|
|
19
20
|
let { module } = req.params;
|
|
20
21
|
let { list = '', type = 'dict', ...extra } = req.query;
|
|
21
22
|
let data = await mapping.getMapping(module, list.split('|'), extra);
|
|
23
|
+
applog.info(`🌟 ~ mapping:`, type, data);
|
|
22
24
|
if (type === 'dict') {
|
|
23
25
|
Reflect.deleteProperty(data, 'list');
|
|
24
26
|
} else if (type === 'list') {
|