mm-share-lib 0.0.30 → 0.0.32
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/src/exception/bad-request-error.exception.d.ts +1 -1
- package/dist/src/exception/bad-request-error.exception.js +2 -2
- package/dist/src/exception/bad-request-error.exception.js.map +1 -1
- package/dist/src/exception/base.exception.d.ts +1 -1
- package/dist/src/exception/base.exception.js +4 -1
- package/dist/src/exception/base.exception.js.map +1 -1
- package/dist/src/exception/conflict-error.exception.d.ts +1 -1
- package/dist/src/exception/conflict-error.exception.js +2 -2
- package/dist/src/exception/conflict-error.exception.js.map +1 -1
- package/dist/src/exception/forbidden-error.exception.d.ts +1 -1
- package/dist/src/exception/forbidden-error.exception.js +2 -2
- package/dist/src/exception/forbidden-error.exception.js.map +1 -1
- package/dist/src/exception/internal-server-error.exception.d.ts +1 -1
- package/dist/src/exception/internal-server-error.exception.js +2 -2
- package/dist/src/exception/internal-server-error.exception.js.map +1 -1
- package/dist/src/exception/not-found-error.exception.d.ts +1 -1
- package/dist/src/exception/not-found-error.exception.js +2 -2
- package/dist/src/exception/not-found-error.exception.js.map +1 -1
- package/dist/src/exception/unauthorized-error.exception.d.ts +1 -1
- package/dist/src/exception/unauthorized-error.exception.js +2 -2
- package/dist/src/exception/unauthorized-error.exception.js.map +1 -1
- package/dist/src/lib/{datasource-mapper/datasource-mapper.d.ts → datasource/datasource-manager.d.ts} +3 -3
- package/dist/src/lib/{datasource-mapper/datasource-mapper.js → datasource/datasource-manager.js} +14 -7
- package/dist/src/lib/datasource/datasource-manager.js.map +1 -0
- package/dist/src/lib/datasource/index.d.ts +1 -0
- package/dist/src/lib/{datasource-mapper → datasource}/index.js +1 -1
- package/dist/src/lib/datasource/index.js.map +1 -0
- package/dist/src/lib/index.d.ts +1 -1
- package/dist/src/lib/index.js +1 -1
- package/dist/src/lib/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/exception/bad-request-error.exception.ts +7 -2
- package/src/exception/base.exception.ts +4 -1
- package/src/exception/conflict-error.exception.ts +7 -2
- package/src/exception/forbidden-error.exception.ts +7 -2
- package/src/exception/internal-server-error.exception.ts +2 -1
- package/src/exception/not-found-error.exception.ts +7 -2
- package/src/exception/unauthorized-error.exception.ts +2 -1
- package/src/lib/{datasource-mapper/datasource-mapper.ts → datasource/datasource-manager.ts} +17 -5
- package/src/lib/datasource/index.ts +1 -0
- package/src/lib/index.ts +1 -1
- package/dist/src/lib/datasource-mapper/datasource-mapper.js.map +0 -1
- package/dist/src/lib/datasource-mapper/index.d.ts +0 -1
- package/dist/src/lib/datasource-mapper/index.js.map +0 -1
- package/src/lib/datasource-mapper/index.ts +0 -1
package/package.json
CHANGED
@@ -2,7 +2,12 @@ import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { BaseException, ParametersType } from './base.exception';
|
3
3
|
|
4
4
|
export class BadRequestException extends BaseException {
|
5
|
-
constructor(message?: string, parameters?: ParametersType) {
|
6
|
-
super(
|
5
|
+
constructor(message?: string, code?: string, parameters?: ParametersType) {
|
6
|
+
super(
|
7
|
+
message ?? 'BadRequestException',
|
8
|
+
HttpStatus.BAD_REQUEST,
|
9
|
+
code,
|
10
|
+
parameters,
|
11
|
+
);
|
7
12
|
}
|
8
13
|
}
|
@@ -22,14 +22,17 @@ export class BaseException extends HttpException {
|
|
22
22
|
constructor(
|
23
23
|
message: string,
|
24
24
|
status: HttpStatus,
|
25
|
+
code?: string,
|
25
26
|
parameters?: ParametersType,
|
26
27
|
) {
|
27
28
|
super(message, status);
|
28
29
|
|
30
|
+
if (code) {
|
31
|
+
this.code = code;
|
32
|
+
}
|
29
33
|
if (parameters) {
|
30
34
|
this.parameters = parameters;
|
31
35
|
}
|
32
|
-
|
33
36
|
this.statusCode = super.getStatus();
|
34
37
|
Error.captureStackTrace(this);
|
35
38
|
}
|
@@ -2,7 +2,12 @@ import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { BaseException, ParametersType } from './base.exception';
|
3
3
|
|
4
4
|
export class ConflictException extends BaseException {
|
5
|
-
constructor(message?: string, parameters?: ParametersType) {
|
6
|
-
super(
|
5
|
+
constructor(message?: string, code?: string, parameters?: ParametersType) {
|
6
|
+
super(
|
7
|
+
message ?? 'ConflictException',
|
8
|
+
HttpStatus.CONFLICT,
|
9
|
+
code,
|
10
|
+
parameters,
|
11
|
+
);
|
7
12
|
}
|
8
13
|
}
|
@@ -2,7 +2,12 @@ import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { BaseException, ParametersType } from './base.exception';
|
3
3
|
|
4
4
|
export class ForbiddenException extends BaseException {
|
5
|
-
constructor(message?: string, parameters?: ParametersType) {
|
6
|
-
super(
|
5
|
+
constructor(message?: string, code?: string, parameters?: ParametersType) {
|
6
|
+
super(
|
7
|
+
message ?? 'BadRequestException',
|
8
|
+
HttpStatus.FORBIDDEN,
|
9
|
+
code,
|
10
|
+
parameters,
|
11
|
+
);
|
7
12
|
}
|
8
13
|
}
|
@@ -2,10 +2,11 @@ import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { BaseException, ParametersType } from './base.exception';
|
3
3
|
|
4
4
|
export class InternalServerException extends BaseException {
|
5
|
-
constructor(message?: string, parameters?: ParametersType) {
|
5
|
+
constructor(message?: string, code?: string, parameters?: ParametersType) {
|
6
6
|
super(
|
7
7
|
message ?? 'InternalServerException',
|
8
8
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
9
|
+
code,
|
9
10
|
parameters,
|
10
11
|
);
|
11
12
|
}
|
@@ -2,7 +2,12 @@ import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { BaseException, ParametersType } from './base.exception';
|
3
3
|
|
4
4
|
export class NotFoundException extends BaseException {
|
5
|
-
constructor(message?: string, parameters?: ParametersType) {
|
6
|
-
super(
|
5
|
+
constructor(message?: string, code?: string, parameters?: ParametersType) {
|
6
|
+
super(
|
7
|
+
message ?? 'NotFoundException',
|
8
|
+
HttpStatus.NOT_FOUND,
|
9
|
+
code,
|
10
|
+
parameters,
|
11
|
+
);
|
7
12
|
}
|
8
13
|
}
|
@@ -2,10 +2,11 @@ import { HttpStatus } from '@nestjs/common';
|
|
2
2
|
import { BaseException, ParametersType } from './base.exception';
|
3
3
|
|
4
4
|
export class UnauthorizedException extends BaseException {
|
5
|
-
constructor(message?: string, parameters?: ParametersType) {
|
5
|
+
constructor(message?: string, code?: string, parameters?: ParametersType) {
|
6
6
|
super(
|
7
7
|
message ?? 'UnauthorizedException',
|
8
8
|
HttpStatus.UNAUTHORIZED,
|
9
|
+
code,
|
9
10
|
parameters,
|
10
11
|
);
|
11
12
|
}
|
@@ -5,17 +5,20 @@ export class DataSourceManager {
|
|
5
5
|
|
6
6
|
private readonly dataSources: { [key: string]: DataSource } = {};
|
7
7
|
|
8
|
-
private constructor(
|
8
|
+
private constructor() {}
|
9
9
|
|
10
|
-
public static getInstance(
|
10
|
+
public static getInstance(): DataSourceManager {
|
11
11
|
if (!DataSourceManager.instance) {
|
12
|
-
DataSourceManager.instance = new DataSourceManager(
|
12
|
+
DataSourceManager.instance = new DataSourceManager();
|
13
13
|
}
|
14
14
|
|
15
15
|
return DataSourceManager.instance;
|
16
16
|
}
|
17
17
|
|
18
|
-
async getDataSource(
|
18
|
+
async getDataSource(
|
19
|
+
dataSourceName: string,
|
20
|
+
options: DataSourceOptions,
|
21
|
+
): Promise<DataSource> {
|
19
22
|
if (this.dataSources[dataSourceName]) {
|
20
23
|
const dataSource = this.dataSources[dataSourceName];
|
21
24
|
return dataSource.isInitialized
|
@@ -23,10 +26,19 @@ export class DataSourceManager {
|
|
23
26
|
: await dataSource.initialize();
|
24
27
|
}
|
25
28
|
|
26
|
-
const newDataSource = new DataSource(
|
29
|
+
const newDataSource = new DataSource(options);
|
27
30
|
|
28
31
|
this.dataSources[dataSourceName] = newDataSource;
|
29
32
|
|
30
33
|
return newDataSource.initialize();
|
31
34
|
}
|
35
|
+
|
36
|
+
async close(): Promise<void> {
|
37
|
+
for (const key in this.dataSources) {
|
38
|
+
const dataSource = this.dataSources[key];
|
39
|
+
if (dataSource.isInitialized) {
|
40
|
+
await dataSource.destroy();
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
32
44
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './datasource-manager';
|
package/src/lib/index.ts
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"datasource-mapper.js","sourceRoot":"","sources":["../../../../src/lib/datasource-mapper/datasource-mapper.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AAExD,MAAa,iBAAiB;IAK5B,YAA4B,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;QAFrC,gBAAW,GAAkC,EAAE,CAAC;IAER,CAAC;IAEnD,MAAM,CAAC,WAAW,CAAC,OAA0B;QAClD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE;YAC/B,iBAAiB,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;SAC7D;QAED,OAAO,iBAAiB,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,cAAsB;QACxC,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE;YACpC,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;YACpD,OAAO,UAAU,CAAC,aAAa;gBAC7B,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC;SACnC;QAED,MAAM,aAAa,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnD,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC;QAEjD,OAAO,aAAa,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;CACF;AA7BD,8CA6BC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './datasource-mapper';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/datasource-mapper/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './datasource-mapper';
|