@digione/node-custom-api 0.1.9-alpha16 → 0.1.9-alpha17
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.
|
@@ -14,3 +14,6 @@ export declare const changeBodyParam: (value?: {}, { skipSystem, omit }?: {
|
|
|
14
14
|
skipSystem?: boolean;
|
|
15
15
|
omit?: any[];
|
|
16
16
|
}) => (req: Request, res: Response, next: any) => any;
|
|
17
|
+
export declare const changeConfigParam: (value?: {}, { skipSystem }?: {
|
|
18
|
+
skipSystem?: boolean;
|
|
19
|
+
}) => (req: Request, res: Response, next: any) => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeBodyParam = exports.changeOptionParam = exports.changeQueryParam = exports.getQueryParamFile = exports.getQueryParamCUD = exports.getQueryParam = exports.getStremParam = exports.getAuthParam = void 0;
|
|
3
|
+
exports.changeConfigParam = exports.changeBodyParam = exports.changeOptionParam = exports.changeQueryParam = exports.getQueryParamFile = exports.getQueryParamCUD = exports.getQueryParam = exports.getStremParam = exports.getAuthParam = void 0;
|
|
4
4
|
const helper_1 = require("../utils/helper");
|
|
5
5
|
const _ = require("lodash");
|
|
6
6
|
const getAuthParam = (req, res, next) => {
|
|
@@ -127,6 +127,7 @@ const getQueryParam = (req, res, next) => {
|
|
|
127
127
|
};
|
|
128
128
|
exports.getQueryParam = getQueryParam;
|
|
129
129
|
const getQueryParamCUD = (req, res, next) => {
|
|
130
|
+
let config = res.locals.config || {};
|
|
130
131
|
res.locals.option = res.locals.option || {};
|
|
131
132
|
if (req.query.include) {
|
|
132
133
|
try {
|
|
@@ -144,7 +145,7 @@ const getQueryParamCUD = (req, res, next) => {
|
|
|
144
145
|
res.locals.option['records'] = String(req.query.records).split(',');
|
|
145
146
|
}
|
|
146
147
|
if (req.query.ids) {
|
|
147
|
-
res.locals.option['ids'] = String(req.query.ids).split(',').slice(0, 25);
|
|
148
|
+
res.locals.option['ids'] = String(req.query.ids).split(',').slice(0, (config['maxQueryIds'] || 25));
|
|
148
149
|
}
|
|
149
150
|
return (0, exports.getAuthParam)(req, res, () => {
|
|
150
151
|
if (req.query.lang_code) {
|
|
@@ -218,3 +219,13 @@ const changeBodyParam = (value = {}, { skipSystem = false, omit = [] } = {}) =>
|
|
|
218
219
|
return next();
|
|
219
220
|
};
|
|
220
221
|
exports.changeBodyParam = changeBodyParam;
|
|
222
|
+
const changeConfigParam = (value = {}, { skipSystem = false } = {}) => (req, res, next) => {
|
|
223
|
+
if (skipSystem && req.params.web_system_token) {
|
|
224
|
+
let bol = (typeof req.params.web != "undefined") || (req.params.web_system == req.params.web);
|
|
225
|
+
if (bol)
|
|
226
|
+
return next();
|
|
227
|
+
}
|
|
228
|
+
res.locals.config = Object.assign(Object.assign({}, res.locals.config || {}), value);
|
|
229
|
+
return next();
|
|
230
|
+
};
|
|
231
|
+
exports.changeConfigParam = changeConfigParam;
|
package/package.json
CHANGED
package/utils/validator.js
CHANGED
|
@@ -240,8 +240,9 @@ const exportService = ({ file_type = undefined, export_type = [], limit = 200, s
|
|
|
240
240
|
});
|
|
241
241
|
exports.exportService = exportService;
|
|
242
242
|
const printService = ({ print_type = [], schema = {} } = {}) => (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
243
|
+
let config = res.locals.config || {};
|
|
243
244
|
if (req.query.ids) {
|
|
244
|
-
res.locals.option = Object.assign(Object.assign({}, (res.locals.option || {})), { ids: String(req.query.ids).split(',') });
|
|
245
|
+
res.locals.option = Object.assign(Object.assign({}, (res.locals.option || {})), { ids: String(req.query.ids).split(',').slice(0, (config['maxQueryIds'] || 25)) });
|
|
245
246
|
}
|
|
246
247
|
if (print_type && !req.query.print_type) {
|
|
247
248
|
req.query.print_type = print_type[0];
|
|
@@ -261,8 +262,9 @@ const printService = ({ print_type = [], schema = {} } = {}) => (req, res, next)
|
|
|
261
262
|
});
|
|
262
263
|
exports.printService = printService;
|
|
263
264
|
const dataService = ({ schema = {} } = {}) => (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
265
|
+
let config = res.locals.config || {};
|
|
264
266
|
if (req.query.ids) {
|
|
265
|
-
res.locals.option = Object.assign(Object.assign({}, (res.locals.option || {})), { ids: String(req.query.ids).split(',') });
|
|
267
|
+
res.locals.option = Object.assign(Object.assign({}, (res.locals.option || {})), { ids: String(req.query.ids).split(',').slice(0, (config['maxQueryIds'] || 25)) });
|
|
266
268
|
}
|
|
267
269
|
let option = Object.keys(schema || {});
|
|
268
270
|
if (option.length) {
|