@digione/node-custom-api 0.1.9-beta1 → 0.1.9-beta2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digione/node-custom-api",
3
- "version": "0.1.9-beta1",
3
+ "version": "0.1.9-beta2",
4
4
  "description": "Typescript node digione-api",
5
5
  "author": "Monchai Jirayupong <monchai.j@seven.co.th>",
6
6
  "license": "MIT",
@@ -57,5 +57,13 @@ export declare const convertService: ({ convert_type, schema }?: {
57
57
  convert_type?: any[];
58
58
  schema?: {};
59
59
  }) => (req: any, res: any, next: any) => Promise<any>;
60
+ export declare const entryValidateService: ({ module, schema }?: {
61
+ module?: string[];
62
+ schema?: {};
63
+ }) => (req: any, res: any, next: any) => Promise<any>;
64
+ export declare const entryParamService: ({ module, schema }?: {
65
+ module?: string[];
66
+ schema?: {};
67
+ }) => (req: any, res: any, next: any) => Promise<any>;
60
68
  export declare const createdByValidate: (req: any, res: any, next: any) => Promise<any>;
61
69
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createdByValidate = exports.convertService = exports.fieldService = exports.dataService = exports.printService = exports.exportService = exports.importService = exports.streamService = exports.multiService = exports.fileService = exports.paramService = exports.validateService = exports.validate = void 0;
3
+ exports.createdByValidate = exports.entryParamService = exports.entryValidateService = exports.convertService = exports.fieldService = exports.dataService = exports.printService = exports.exportService = exports.importService = exports.streamService = exports.multiService = exports.fileService = exports.paramService = exports.validateService = exports.validate = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Joi = require("joi");
6
6
  const errors_1 = require("../errors");
@@ -291,6 +291,20 @@ const convertService = ({ convert_type = [], schema = {} } = {}) => (req, res, n
291
291
  return (0, exports.validateService)(Joi.object().keys(Object.assign({ ids: Joi.array().items(Joi.number()).min(1), convert_type: Joi.string().valid(...convert_type) }, schema)).unknown())(req, res, next);
292
292
  });
293
293
  exports.convertService = convertService;
294
+ const entryValidateService = ({ module = ['contact'], schema = {} } = {}) => (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
295
+ return (0, exports.validateService)(Joi.object().keys(Object.assign({ module: Joi.string().valid(...module), entry_id: Joi.number().required() }, schema)).unknown())(req, res, next);
296
+ });
297
+ exports.entryValidateService = entryValidateService;
298
+ const entryParamService = ({ module = ['contact'], schema = {} } = {}) => (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
299
+ if (req.query.module) {
300
+ res.locals.option = Object.assign(Object.assign({}, (res.locals.option || {})), { module: req.query.module });
301
+ }
302
+ if (req.query.entry_id) {
303
+ res.locals.option = Object.assign(Object.assign({}, (res.locals.option || {})), { entry_id: req.query.entry_id });
304
+ }
305
+ return (0, exports.paramService)(Joi.object().keys(Object.assign({ module: Joi.string().valid(...module), entry_id: Joi.number().required() }, schema)).unknown())(req, res, next);
306
+ });
307
+ exports.entryParamService = entryParamService;
294
308
  exports.createdByValidate = (0, exports.validateService)(Joi.object().keys({
295
309
  created_by: Joi.alternatives().try(Joi.string(), Joi.number()).required()
296
310
  }).unknown());