@digione/node-custom-api 0.1.9-alpha16 → 0.1.9-alpha18

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digione/node-custom-api",
3
- "version": "0.1.9-alpha16",
3
+ "version": "0.1.9-alpha18",
4
4
  "description": "Typescript node digione-api",
5
5
  "author": "Monchai Jirayupong <monchai.j@seven.co.th>",
6
6
  "license": "MIT",
package/utils/helper.d.ts CHANGED
@@ -92,6 +92,7 @@ export declare const slugify: (string?: any, { lowercase }?: {
92
92
  }) => any;
93
93
  export declare const slugifyField: (string?: any) => any;
94
94
  export declare const stripHtml: (string: string) => string;
95
+ export declare const stripEmoji: (string: string) => string;
95
96
  export declare const replaceColon: (string: string, { decode }?: {
96
97
  decode?: boolean;
97
98
  }) => string;
package/utils/helper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertCurrency = exports.xorMerge = exports.xorDecode = exports.xorEncode = exports.getInstanceNumber = exports.getDomain = exports.getParent = exports.replaceColon = exports.stripHtml = exports.slugifyField = exports.slugify = exports.convertToBigEndian = exports.expandTree = exports.buildTree = exports.treeToArray = exports.randomRef = exports.multiExecArray = exports.isBase64 = exports.isNumber = exports.removeAt = exports.removeSpace = exports.formatMobileNumber = exports.getMobileNumber = exports.removeHyphen = exports.signToken = exports.getTokenDataFromTokenBySecret = exports.getUUID32 = exports.getUUID = exports.sleep = exports.getValueByLang = exports.getValueFunctionLang = exports.getValueFunctionFile = exports.getDateTime = exports.getTimestampMysql = exports.getDateMysql = exports.getSlug = exports.getENV = exports.Joi_date = exports.getDaysBetweenDates = exports.getDateFromString = exports.getDateRangeFormat = void 0;
3
+ exports.convertCurrency = exports.xorMerge = exports.xorDecode = exports.xorEncode = exports.getInstanceNumber = exports.getDomain = exports.getParent = exports.replaceColon = exports.stripEmoji = exports.stripHtml = exports.slugifyField = exports.slugify = exports.convertToBigEndian = exports.expandTree = exports.buildTree = exports.treeToArray = exports.randomRef = exports.multiExecArray = exports.isBase64 = exports.isNumber = exports.removeAt = exports.removeSpace = exports.formatMobileNumber = exports.getMobileNumber = exports.removeHyphen = exports.signToken = exports.getTokenDataFromTokenBySecret = exports.getUUID32 = exports.getUUID = exports.sleep = exports.getValueByLang = exports.getValueFunctionLang = exports.getValueFunctionFile = exports.getDateTime = exports.getTimestampMysql = exports.getDateMysql = exports.getSlug = exports.getENV = exports.Joi_date = exports.getDaysBetweenDates = exports.getDateFromString = exports.getDateRangeFormat = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const crypto = require("crypto");
6
6
  const dotenv = require("dotenv");
@@ -366,6 +366,10 @@ const stripHtml = (string) => {
366
366
  .replace(/\n/g, '');
367
367
  };
368
368
  exports.stripHtml = stripHtml;
369
+ const stripEmoji = (string) => {
370
+ return String(string).replace(/(?![*#0-9]+)[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]/gu, '').trim();
371
+ };
372
+ exports.stripEmoji = stripEmoji;
369
373
  const replaceColon = (string, { decode = false } = {}) => {
370
374
  if (!string || typeof (string) != 'string') {
371
375
  return string;
package/utils/metadata.js CHANGED
@@ -27,11 +27,11 @@ class MetadataUtil {
27
27
  let value = {}, type = types;
28
28
  if (_.isObject(input[key])) {
29
29
  let val = {};
30
- _.each(input[key], (v, k) => { val['value_' + k] = (0, helper_1.stripHtml)(v ? v.substring(0, str_length) : ""); });
30
+ _.each(input[key], (v, k) => { val['value_' + k] = v ? (0, helper_1.stripEmoji)((0, helper_1.stripHtml)(v)).substring(0, str_length) : ""; });
31
31
  value = val;
32
32
  }
33
33
  else {
34
- value = { value_en: (0, helper_1.stripHtml)(String(input[key] || "").substring(0, str_length)) };
34
+ value = { value_en: (0, helper_1.stripEmoji)((0, helper_1.stripHtml)(String(input[key] || "")).substring(0, str_length)) };
35
35
  }
36
36
  if (autoType && !items[key]) {
37
37
  let str = key.split(":");
@@ -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) {