@samet-it/be-base-common 1.1.5 → 1.3.1
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/config/base-common.config.d.ts +1 -1
- package/dist/config/index.types.d.ts +2 -2
- package/dist/error/error.handler.d.ts +1 -1
- package/dist/error/error.handler.js +3 -3
- package/dist/error/index.types.d.ts +1 -1
- package/dist/error/items/page-not-found.error.d.ts +4 -2
- package/dist/error/items/page-not-found.error.js +3 -2
- package/dist/error/items/record-duplicated.error.d.ts +4 -2
- package/dist/error/items/record-duplicated.error.js +3 -2
- package/dist/error/items/record-not-found.error.d.ts +4 -2
- package/dist/error/items/record-not-found.error.js +3 -2
- package/dist/error/items/samet.error.d.ts +1 -1
- package/dist/error/items/validation.error.d.ts +4 -2
- package/dist/error/items/validation.error.js +3 -2
- package/dist/exit/exit-handler.impl.js +7 -3
- package/dist/logger/index.types.d.ts +4 -4
- package/dist/logger/logger.impl.d.ts +1 -1
- package/dist/logger/logger.impl.js +4 -4
- package/dist/model/index.types.js +1 -0
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseCommonConf } from "./index.types";
|
|
2
2
|
export declare const baseCommonConfig: import("@leyyo/env").EnvScopeRuntime<BaseCommonConf, undefined, undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ErrorHandlerLike } from "./index.types";
|
|
2
2
|
export declare const errorHandler: ErrorHandlerLike;
|
|
@@ -6,10 +6,10 @@ class ErrorHandler {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
this._CLEAR_STAT = 1000 * 60 * 60 * 24; // daily
|
|
8
8
|
this._stats = new Map();
|
|
9
|
-
this.common = common_1
|
|
9
|
+
this.common = common_1.errorCommon;
|
|
10
10
|
this.started = new Date();
|
|
11
|
-
common_1
|
|
12
|
-
common_1
|
|
11
|
+
common_1.errorCommon.addKnownPackage('@samet-it', 's');
|
|
12
|
+
common_1.errorCommon.addKnownPackage('@nestjs', 'n');
|
|
13
13
|
this._clearStats();
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error";
|
|
3
|
+
export declare class PageNotFoundError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(path: string, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PageNotFoundError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const samet_error_1 = require("./samet.error");
|
|
5
5
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class PageNotFoundError extends
|
|
6
|
+
class PageNotFoundError extends samet_error_1.SametError {
|
|
7
7
|
constructor(path, opt) {
|
|
8
8
|
super(`Path: ${path} is not found`, Object.assign(Object.assign({}, opt), { path }));
|
|
9
|
+
this.status = 404;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.PageNotFoundError = PageNotFoundError;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error";
|
|
3
|
+
export declare class RecordDuplicatedError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(domain: string, query: Record<string, unknown>, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RecordDuplicatedError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const samet_error_1 = require("./samet.error");
|
|
5
5
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class RecordDuplicatedError extends
|
|
6
|
+
class RecordDuplicatedError extends samet_error_1.SametError {
|
|
7
7
|
constructor(domain, query, opt) {
|
|
8
8
|
super(`${domain} record is duplicated`, Object.assign(Object.assign({}, opt), { domain, query }));
|
|
9
|
+
this.status = 409;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.RecordDuplicatedError = RecordDuplicatedError;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error";
|
|
3
|
+
export declare class RecordNotFoundError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(domain: string, query: Record<string, unknown>, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RecordNotFoundError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const samet_error_1 = require("./samet.error");
|
|
5
5
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class RecordNotFoundError extends
|
|
6
|
+
class RecordNotFoundError extends samet_error_1.SametError {
|
|
7
7
|
constructor(domain, query, opt) {
|
|
8
8
|
super(`${domain} record could not be found`, Object.assign(Object.assign({}, opt), { domain, query }));
|
|
9
|
+
this.status = 400;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.RecordNotFoundError = RecordNotFoundError;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Opt } from "@leyyo/common";
|
|
2
|
+
import { SametError } from "./samet.error";
|
|
3
|
+
export declare class ValidationError extends SametError {
|
|
4
|
+
status: number;
|
|
3
5
|
constructor(domain: string, key: string, value?: unknown, opt?: Opt);
|
|
4
6
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ValidationError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const samet_error_1 = require("./samet.error");
|
|
5
5
|
// noinspection JSUnusedGlobalSymbols
|
|
6
|
-
class ValidationError extends
|
|
6
|
+
class ValidationError extends samet_error_1.SametError {
|
|
7
7
|
constructor(domain, key, value, opt) {
|
|
8
8
|
super(`${domain} -> ${key} is invalid`, Object.assign(Object.assign({}, opt), { domain, key, value }));
|
|
9
|
+
this.status = 400;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.ValidationError = ValidationError;
|
|
@@ -4,9 +4,13 @@ exports.exitHandler = void 0;
|
|
|
4
4
|
class ExitHandlerImpl {
|
|
5
5
|
register(fn) {
|
|
6
6
|
['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGKILL'].forEach(event => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
try {
|
|
8
|
+
process.on(event, () => {
|
|
9
|
+
fn(`${event} event received`);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
}
|
|
10
14
|
});
|
|
11
15
|
}
|
|
12
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ClassLike, Obj, Logger } from "@leyyo/common";
|
|
2
2
|
/**
|
|
3
3
|
* Logger pool interface
|
|
4
4
|
* */
|
|
@@ -9,21 +9,21 @@ export interface LoggerLike {
|
|
|
9
9
|
* @param {string} className - class name
|
|
10
10
|
* @return {Logger} - logger instance
|
|
11
11
|
* */
|
|
12
|
-
|
|
12
|
+
of(className: string): Logger;
|
|
13
13
|
/**
|
|
14
14
|
* Create logger by class
|
|
15
15
|
*
|
|
16
16
|
* @param {function} clazz - class
|
|
17
17
|
* @return {Logger} - logger instance
|
|
18
18
|
* */
|
|
19
|
-
|
|
19
|
+
of(clazz: ClassLike): Logger;
|
|
20
20
|
/**
|
|
21
21
|
* Create logger by instance
|
|
22
22
|
*
|
|
23
23
|
* @param {Obj} instance - instance, ie: `this`
|
|
24
24
|
* @return {Logger} - logger instance
|
|
25
25
|
* */
|
|
26
|
-
|
|
26
|
+
of(instance: Obj): Logger;
|
|
27
27
|
/**
|
|
28
28
|
* Get samet default logger
|
|
29
29
|
*
|
|
@@ -12,20 +12,20 @@ class LoggerImpl {
|
|
|
12
12
|
* @param {(string|ClassLike|Obj)} ref - class name, class or instance
|
|
13
13
|
* @return {Logger} - logger instance
|
|
14
14
|
* */
|
|
15
|
-
|
|
16
|
-
return common_1
|
|
15
|
+
of(ref) {
|
|
16
|
+
return common_1.logCommon.of(ref);
|
|
17
17
|
}
|
|
18
18
|
/** @inheritDoc */
|
|
19
19
|
get samet() {
|
|
20
20
|
if (!this._sametLogger) {
|
|
21
|
-
this._sametLogger = common_1
|
|
21
|
+
this._sametLogger = common_1.logCommon.of('Samet');
|
|
22
22
|
}
|
|
23
23
|
return this._sametLogger;
|
|
24
24
|
}
|
|
25
25
|
/** @inheritDoc */
|
|
26
26
|
get developer() {
|
|
27
27
|
if (!this._developerLogger) {
|
|
28
|
-
this._developerLogger = common_1
|
|
28
|
+
this._developerLogger = common_1.logCommon.of('Developer');
|
|
29
29
|
}
|
|
30
30
|
return this._developerLogger;
|
|
31
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samet-it/be-base-common",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Backend Base Common",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@leyyo/common": "^1.
|
|
67
|
-
"@leyyo/env": "^1.
|
|
68
|
-
"@leyyo/asl": "^1.
|
|
66
|
+
"@leyyo/common": "^1.3.7",
|
|
67
|
+
"@leyyo/env": "^1.3.3",
|
|
68
|
+
"@leyyo/asl": "^1.3.3"
|
|
69
69
|
}
|
|
70
70
|
}
|