@digione/node-custom-api 0.1.9-beta15 → 0.1.9-beta16
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/middlewares/paramQuery.d.ts +3 -0
- package/middlewares/paramQuery.js +13 -2
- package/package.json +1 -1
- package/utils/file.d.ts +2 -1
- package/utils/file.js +2 -2
- package/utils/validator.js +4 -2
|
@@ -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['query_ids'] || 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/file.d.ts
CHANGED
|
@@ -191,7 +191,8 @@ export declare class FileUtil {
|
|
|
191
191
|
width?: number;
|
|
192
192
|
height?: number;
|
|
193
193
|
}): any;
|
|
194
|
-
uploadRawFormat(files: Array<any>, { field }?: {
|
|
194
|
+
uploadRawFormat(files: Array<any>, { format, field }?: {
|
|
195
|
+
format?: boolean;
|
|
195
196
|
field?: string[];
|
|
196
197
|
}): Promise<any>;
|
|
197
198
|
updateFile(id: string, input?: any, { paths }?: {
|
package/utils/file.js
CHANGED
|
@@ -642,10 +642,10 @@ class FileUtil {
|
|
|
642
642
|
}
|
|
643
643
|
});
|
|
644
644
|
}
|
|
645
|
-
uploadRawFormat(files, { field = ['name', 'filename', 'path', 'mimetype', 'filesize', 'extension', 'type', 'height', 'width'] } = {}) {
|
|
645
|
+
uploadRawFormat(files, { format = false, field = ['name', 'filename', 'path', 'mimetype', 'filesize', 'extension', 'type', 'height', 'width'] } = {}) {
|
|
646
646
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
647
647
|
let query = yield this.uploadRaw(files);
|
|
648
|
-
return yield this.formatFile(0, 0, files, query, { format
|
|
648
|
+
return yield this.formatFile(0, 0, files, query, { format, field });
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
651
|
updateFile(id, input = {}, { paths = [] } = {}) {
|
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['query_ids'] || 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['query_ids'] || 25)) });
|
|
266
268
|
}
|
|
267
269
|
let option = Object.keys(schema || {});
|
|
268
270
|
if (option.length) {
|