skyeye-svc-common-utils 1.0.5 → 1.0.7

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": "skyeye-svc-common-utils",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "node-fetch": "^2.6.0",
57
57
  "nyc": "^15.1.0",
58
58
  "rotating-file-stream": "^1.4.6",
59
- "skyeye-common-const": "1.0.2",
59
+ "skyeye-common-const": "1.0.3",
60
60
  "swagger-jsdoc": "^3.5.0",
61
61
  "swagger-ui-express": "^4.1.3",
62
62
  "ts-node": "^9.0.0",
@@ -1,5 +1,8 @@
1
1
  import { ServiceResponse, UserInfo } from "../interfaces";
2
2
  import { QueryRunner } from "typeorm";
3
+ import { commonAppConst, jsonContentTypeHeaders } from "../utils/appConst";
4
+ import { generateJWT } from "../utils/commonUtils";
5
+ import { httpRequest } from "../lib/httpClient";
3
6
 
4
7
  export class BaseControllerParameter {
5
8
  queryRunner: QueryRunner;
@@ -8,5 +11,12 @@ export class BaseControllerParameter {
8
11
 
9
12
  constructor() {
10
13
  }
11
- }
12
-
14
+ async sendInternalHttpRequest(method: string, url : string, data: any = null,) {
15
+ let headers:any = jsonContentTypeHeaders();
16
+ let token: string = `${commonAppConst.httpHeader.BEARER} ${await generateJWT(this.userInfo)}`;
17
+ headers[commonAppConst.httpHeader.AUTHORIZATION] = token;
18
+ return httpRequest(method, url, data, headers).then(response => {
19
+ return response.json()
20
+ })
21
+ }
22
+ }
@@ -1,9 +1,7 @@
1
1
  import { logger } from '../logger/logger';
2
2
  import { ServiceResponse, Pagination, UserInfo } from '../../interfaces';
3
- import { commonAppConst, jsonContentTypeHeaders } from '../../utils/appConst';
3
+ import { commonAppConst } from '../../utils/appConst';
4
4
  import { allApplicationFeatures, ApplicationFeature, commonAppConst as sCommonAppConst, Feature } from 'skyeye-common-const';
5
- import { httpRequest } from '../../lib/httpClient';
6
- import { generateJWT } from './jwtUtils';
7
5
 
8
6
  export async function mappingToModel(input: any, output: any) {
9
7
  if (input !== undefined && input !== null) {
@@ -99,11 +97,4 @@ export async function userInfoToFeatureListByName(userInfo: UserInfo, featureNam
99
97
  } catch (err) {
100
98
  logger.error(err);
101
99
  }
102
- }
103
-
104
- export async function sendInternalHttpRequest(userInfo:UserInfo, method: string, url : string, data: any = null,) {
105
- let headers:any = jsonContentTypeHeaders();
106
- let token: string = `${commonAppConst.httpHeader.BEARER} ${await generateJWT(userInfo)}`;
107
- headers[commonAppConst.httpHeader.AUTHORIZATION] = token;
108
- return httpRequest(method, url, data, headers)
109
100
  }