@bearei/server-common 0.0.2 → 0.0.4
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/dist/action-log/action-log.service.js +1 -1
- package/dist/action-log/action-log.service.js.map +1 -1
- package/dist/app.dto.d.ts +1 -2
- package/dist/app.dto.js +4 -9
- package/dist/app.dto.js.map +1 -1
- package/dist/app.entity.js +2 -10
- package/dist/app.entity.js.map +1 -1
- package/dist/authentication/access/access.guard.js +3 -3
- package/dist/authentication/access/access.guard.js.map +1 -1
- package/dist/authentication/auth/auth.interface.d.ts +1 -2
- package/dist/authentication/auth/auth.service.d.ts +4 -3
- package/dist/authentication/auth/auth.service.js +4 -4
- package/dist/authentication/auth/auth.service.js.map +1 -1
- package/dist/authentication/permission/permission.guard.js +1 -1
- package/dist/authentication/permission/permission.guard.js.map +1 -1
- package/dist/base/base.interface.d.ts +5 -7
- package/dist/base/base.service.d.ts +4 -4
- package/dist/base/base.service.js +107 -79
- package/dist/base/base.service.js.map +1 -1
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +1 -0
- package/dist/base/index.js.map +1 -1
- package/dist/common.d.ts +1 -0
- package/dist/common.js +36 -1
- package/dist/common.js.map +1 -1
- package/dist/external/external.interface.d.ts +11 -15
- package/dist/external/external.service.d.ts +6 -5
- package/dist/external/external.service.js +35 -37
- package/dist/external/external.service.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/util/error.util.d.ts +2 -2
- package/dist/util/error.util.js +5 -5
- package/dist/util/error.util.js.map +1 -1
- package/dist/util/format.util.d.ts +1 -1
- package/dist/util/format.util.js +1 -1
- package/dist/util/format.util.js.map +1 -1
- package/dist/util/util.interface.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { APIError } from '../app.interface';
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
2
|
+
import { ThrowAPIErrorOptions } from './util.interface';
|
|
3
|
+
export declare const throwAPIError: (options: ThrowAPIErrorOptions) => (apiError: APIError) => never;
|
package/dist/util/error.util.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.throwAPIError = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const app_interface_1 = require("../app.interface");
|
|
6
|
-
const
|
|
6
|
+
const throwAPIError = (options) => (apiError) => {
|
|
7
7
|
const errorFunctionMap = {
|
|
8
8
|
[app_interface_1.APIError.UNAUTHORIZED]: ({ message = 'Unauthorized', code = 401000 }) => new common_1.default.UnauthorizedException({
|
|
9
9
|
code,
|
|
@@ -35,11 +35,11 @@ const throwError = (options) => (apiError) => {
|
|
|
35
35
|
message,
|
|
36
36
|
statusCode: common_1.default.HttpStatus.INTERNAL_SERVER_ERROR
|
|
37
37
|
}),
|
|
38
|
-
[app_interface_1.APIError.HTTP_EXCEPTION]: ({ response, status }) => new common_1.default.HttpException(
|
|
39
|
-
cause: Object.assign(new Error(), response)
|
|
38
|
+
[app_interface_1.APIError.HTTP_EXCEPTION]: ({ code = 400000, message = 'Bad Request', response, status = 400 }) => new common_1.default.HttpException(response ?? message, status, {
|
|
39
|
+
cause: Object.assign(new Error(), { code, message, ...response })
|
|
40
40
|
})
|
|
41
41
|
};
|
|
42
42
|
throw errorFunctionMap[apiError](options);
|
|
43
43
|
};
|
|
44
|
-
exports.
|
|
44
|
+
exports.throwAPIError = throwAPIError;
|
|
45
45
|
//# sourceMappingURL=error.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.util.js","sourceRoot":"","sources":["../../src/util/error.util.ts"],"names":[],"mappings":";;;AAAA,2CAAmC;AACnC,oDAAyC;AAGlC,MAAM,
|
|
1
|
+
{"version":3,"file":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CAAC,UAAU,CAAC,oBAAoB;SACrD,CAAC;QACN,CAAC,wBAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,EAAC,OAAO,GAAG,uBAAuB,EAAE,IAAI,GAAG,MAAM,EAAuB,EAAE,EAAE,CAC3G,IAAI,gBAAM,CAAC,4BAA4B,CAAC;YACpC,IAAI;YACJ,KAAK,EAAE,uBAAuB;YAC9B,OAAO;YACP,UAAU,EAAE,gBAAM,CAAC,UAAU,CAAC,qBAAqB;SACtD,CAAC;QACN,CAAC,wBAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,EACxB,IAAI,GAAG,MAAM,EACb,OAAO,GAAG,aAAa,EACvB,QAAQ,EACR,MAAM,GAAG,GAAG,EACO,EAAE,EAAE,CACvB,IAAI,gBAAM,CAAC,aAAa,CAAC,QAAQ,IAAI,OAAO,EAAE,MAAM,EAAE;YAClD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,EAAE,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAC,CAAC;SAClE,CAAC;KACT,CAAA;IAED,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAA;AAjDY,QAAA,aAAa,iBAiDzB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { APIHeaders } from '../app.interface';
|
|
2
|
-
export declare const formatMobile: (
|
|
2
|
+
export declare const formatMobile: (regionCode?: string) => (mobile: string) => string;
|
|
3
3
|
export declare const formatToken: (headers: APIHeaders) => string | undefined;
|
package/dist/util/format.util.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatToken = exports.formatMobile = void 0;
|
|
4
|
-
const formatMobile = (
|
|
4
|
+
const formatMobile = (regionCode = '') => (mobile) => `+${regionCode} ${mobile}`;
|
|
5
5
|
exports.formatMobile = formatMobile;
|
|
6
6
|
const formatToken = (headers) => {
|
|
7
7
|
const [type, token] = headers['authorization']?.split(' ') ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.util.js","sourceRoot":"","sources":["../../src/util/format.util.ts"],"names":[],"mappings":";;;AAEO,MAAM,YAAY,GACrB,CAAC,
|
|
1
|
+
{"version":3,"file":"format.util.js","sourceRoot":"","sources":["../../src/util/format.util.ts"],"names":[],"mappings":";;;AAEO,MAAM,YAAY,GACrB,CAAC,UAAU,GAAG,EAAE,EAAE,EAAE,CACpB,CAAC,MAAc,EAAE,EAAE,CACf,IAAI,UAAU,IAAI,MAAM,EAAE,CAAA;AAHrB,QAAA,YAAY,gBAGS;AAE3B,MAAM,WAAW,GAAG,CAAC,OAAmB,EAAsB,EAAE;IACnE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IAEhE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAChD,CAAC,CAAA;AAJY,QAAA,WAAW,eAIvB"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bearei/server-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"author": "bearei <bear_ei@outlook.com>",
|
|
9
|
-
"description": "
|
|
9
|
+
"description": "Bearei project's NestJS service",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "yarn clean && nest build",
|