@konplit-services/common 1.0.116 → 1.0.118

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,3 +1,4 @@
1
+ import { Usage } from "../../../helper";
1
2
  import { StreamEvent, StreamName, Subjects } from "../../subjects";
2
3
  export interface KeyUpdateTimerCompleteEvent {
3
4
  subject: Subjects.KeysUpdatedComplete;
@@ -6,5 +7,6 @@ export interface KeyUpdateTimerCompleteEvent {
6
7
  data: {
7
8
  merchantId: string;
8
9
  accountId: string;
10
+ usage?: Usage;
9
11
  };
10
12
  }
@@ -1,3 +1,4 @@
1
+ import { Usage } from "../../../helper";
1
2
  import { StreamEvent, StreamName, Subjects } from "../../subjects";
2
3
  export declare type DurationTypes = "2hours" | "1day" | "now" | "2days" | "custom";
3
4
  export interface KeyUpdateTimerEvent {
@@ -7,6 +8,7 @@ export interface KeyUpdateTimerEvent {
7
8
  data: {
8
9
  merchantId: string;
9
10
  accountId: string;
11
+ usage?: Usage;
10
12
  durationType: DurationTypes;
11
13
  duration?: number;
12
14
  };
@@ -4,3 +4,4 @@ export * from "./error-handler";
4
4
  export * from "./permission";
5
5
  export * from "./require-auth";
6
6
  export * from "./validate-request";
7
+ export * from "./validate-fields";
@@ -20,3 +20,4 @@ __exportStar(require("./error-handler"), exports);
20
20
  __exportStar(require("./permission"), exports);
21
21
  __exportStar(require("./require-auth"), exports);
22
22
  __exportStar(require("./validate-request"), exports);
23
+ __exportStar(require("./validate-fields"), exports);
@@ -0,0 +1,2 @@
1
+ import { NextFunction, Request, Response } from "express";
2
+ export declare const validAllowedFields: (allowFields: string[]) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.validAllowedFields = void 0;
13
+ const error_codes_1 = require("../helper/errorCodes/error-codes");
14
+ const errors_1 = require("../errors");
15
+ const validAllowedFields = (allowFields) => {
16
+ return (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
17
+ try {
18
+ const submittedFields = Object.keys(req.body);
19
+ const extraFields = submittedFields.filter((field) => !allowFields.includes(field));
20
+ if (extraFields.length > 0) {
21
+ throw new errors_1.BadRequestError(`Extra fields submitted: ${extraFields.join(", ")}`, error_codes_1.error_codes.INVALID_INPUT);
22
+ }
23
+ return next();
24
+ }
25
+ catch (error) {
26
+ console.log();
27
+ throw error;
28
+ }
29
+ });
30
+ };
31
+ exports.validAllowedFields = validAllowedFields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.116",
3
+ "version": "1.0.118",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",