wingbot 3.69.5 → 3.69.6
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/package.json +1 -1
- package/src/Plugins.js +16 -5
package/package.json
CHANGED
package/src/Plugins.js
CHANGED
|
@@ -9,6 +9,7 @@ const Router = require('./Router'); // eslint-disable-line no-unused-vars
|
|
|
9
9
|
const plugins = require('../plugins');
|
|
10
10
|
const RouterWrap = require('./RouterWrap');
|
|
11
11
|
const wrapPluginFunction = require('./utils/wrapPluginFunction');
|
|
12
|
+
const { compileWithState } = require('./utils');
|
|
12
13
|
|
|
13
14
|
/** @typedef {import('./Router').BaseConfiguration} BaseConfiguration */
|
|
14
15
|
|
|
@@ -101,7 +102,7 @@ class Plugins {
|
|
|
101
102
|
*
|
|
102
103
|
* @param {string} name
|
|
103
104
|
* @param {object} [paramsData]
|
|
104
|
-
* @param {Map<string,Function[]>|Object<string,Middleware<S
|
|
105
|
+
* @param {Map<string,Function[]>|Object<string,Middleware<S>|string>} [items]
|
|
105
106
|
* @param {object} [context]
|
|
106
107
|
* @param {boolean} [context.isLastIndex]
|
|
107
108
|
* @param {Router} [context.router]
|
|
@@ -138,10 +139,20 @@ class Plugins {
|
|
|
138
139
|
// @ts-ignore
|
|
139
140
|
useItems = new Map(
|
|
140
141
|
Object.keys(items)
|
|
141
|
-
.map((key) =>
|
|
142
|
-
key
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
.map((key) => {
|
|
143
|
+
const responder = typeof items[key] === 'function'
|
|
144
|
+
? items[key]
|
|
145
|
+
: (req, res) => {
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
const text = compileWithState(req, res, items[key]);
|
|
148
|
+
res.text(text);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return [
|
|
152
|
+
key,
|
|
153
|
+
[responder]
|
|
154
|
+
];
|
|
155
|
+
})
|
|
145
156
|
);
|
|
146
157
|
}
|
|
147
158
|
|