@autofleet/sheilta 1.2.7 → 1.2.8

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.
@@ -1,5 +1,8 @@
1
1
  declare type OrderItem = string | [string, string];
2
2
  declare type SequelizeOrder = string | OrderItem[];
3
+ export declare type FormatPayloadOptions = {
4
+ includeRawPayload?: boolean;
5
+ };
3
6
  declare const formatPayload: ({ order, page, perPage, include, query, attributes, searchTerm, }: {
4
7
  order: any;
5
8
  page?: number;
@@ -1,4 +1,5 @@
1
+ import { FormatPayloadOptions } from '../formatter';
1
2
  export declare const newQueryValidationMiddleware: (inner?: string) => (model: any) => (req: any, res: any, next: any) => Promise<any>;
2
- export declare const newQueryFormatMiddleware: (inner?: string) => (model: any) => (req: any, res: any, next: any) => Promise<any>;
3
+ export declare const newQueryFormatMiddleware: (inner?: string) => (model: any, options?: FormatPayloadOptions) => (req: any, res: any, next: any) => Promise<any>;
3
4
  export declare const queryValidationMiddleware: (model: any) => (req: any, res: any, next: any) => Promise<any>;
4
- export declare const queryFormatMiddleware: (model: any) => (req: any, res: any, next: any) => Promise<any>;
5
+ export declare const queryFormatMiddleware: (model: any, options?: FormatPayloadOptions) => (req: any, res: any, next: any) => Promise<any>;
@@ -55,7 +55,7 @@ exports.newQueryValidationMiddleware = (inner = 'body') => model => (req, res, n
55
55
  });
56
56
  }
57
57
  });
58
- exports.newQueryFormatMiddleware = (inner = 'body') => model => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
58
+ exports.newQueryFormatMiddleware = (inner = 'body') => (model, options = {}) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
59
59
  const { order, page, perPage, include, query, attributes, searchTerm, } = req[inner];
60
60
  const { query: formattedQuery, order: formattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, } = formatter_1.default({
61
61
  query,
@@ -71,6 +71,17 @@ exports.newQueryFormatMiddleware = (inner = 'body') => model => (req, res, next)
71
71
  req[inner].page = formattedPage;
72
72
  req[inner].perPage = formattedPerPage;
73
73
  req[inner].include = formattedInclude;
74
+ if (options.includeRawPayload) {
75
+ req[inner].rawPayload = {
76
+ order,
77
+ page,
78
+ perPage,
79
+ include,
80
+ query,
81
+ attributes,
82
+ searchTerm,
83
+ };
84
+ }
74
85
  return next();
75
86
  });
76
87
  exports.queryValidationMiddleware = exports.newQueryValidationMiddleware();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sheilta",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "manage cache",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",