@otters.ai/common-backend 1.0.67 → 1.0.69

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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {*} req Express req Object
3
+ * @param {*} res Express res Object
4
+ * @param {*} next Express next Function
5
+ */
6
+ export declare const getUserDetails: (userService: any, req: any, res: any, next: any) => Promise<any>;
@@ -0,0 +1,37 @@
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.getUserDetails = void 0;
13
+ /**
14
+ * @param {*} req Express req Object
15
+ * @param {*} res Express res Object
16
+ * @param {*} next Express next Function
17
+ */
18
+ const getUserDetails = (userService, req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
19
+ try {
20
+ if (!req['userId']) {
21
+ return res.status(200).json({ success: false, message: 'User id not found.' });
22
+ }
23
+ let result = yield userService
24
+ .findEntry(req['userId']);
25
+ if (result.flag) {
26
+ req['userDetails'] = result.message;
27
+ next();
28
+ }
29
+ else {
30
+ return res.status(200).json({ success: false, message: result.message });
31
+ }
32
+ }
33
+ catch (e) {
34
+ return next(e);
35
+ }
36
+ });
37
+ exports.getUserDetails = getUserDetails;
@@ -1,2 +1,3 @@
1
1
  export * from './checkToken';
2
2
  export * from './checkIsAdmin';
3
+ export * from './getUserDetails';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./checkToken"), exports);
18
18
  __exportStar(require("./checkIsAdmin"), exports);
19
+ __exportStar(require("./getUserDetails"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otters.ai/common-backend",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",