mongodb-dynamic-api 2.3.1 → 2.3.2
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
|
|
3
|
+
## [2.3.2](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.1...v2.3.2) (2024-05-07)
|
|
4
|
+
|
|
3
5
|
## [2.3.1](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.0...v2.3.1) (2024-05-05)
|
|
4
6
|
|
|
5
7
|
## [2.3.0](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.2.1...v2.3.0) (2024-05-02)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-dynamic-api",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Auto generated CRUD API for MongoDB using NestJS",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "index.js",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"jest-mock-extended": "^3.0.5",
|
|
87
87
|
"jest-sonar-reporter": "^2.0.0",
|
|
88
88
|
"prettier": "^3.2.5",
|
|
89
|
-
"release-it": "^17.
|
|
89
|
+
"release-it": "^17.2.1",
|
|
90
90
|
"source-map-support": "^0.5.21",
|
|
91
91
|
"supertest": "^6.3.4",
|
|
92
92
|
"ts-jest": "^29.1.2",
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
},
|
|
98
98
|
"jest": {
|
|
99
99
|
"clearMocks": true,
|
|
100
|
-
"resetMocks": true,
|
|
101
100
|
"moduleFileExtensions": [
|
|
102
101
|
"js",
|
|
103
102
|
"json",
|
|
@@ -7,6 +7,5 @@ export declare class DynamicApiModule {
|
|
|
7
7
|
static forRoot<Entity extends BaseEntity = any>(uri: string, { useGlobalCache, cacheOptions, useAuth, routesConfig, }?: DynamicApiForRootOptions<Entity>): DynamicModule;
|
|
8
8
|
static forFeature<Entity extends BaseEntity>({ entity, controllerOptions, routes, }: DynamicApiForFeatureOptions<Entity>): Promise<DynamicModule>;
|
|
9
9
|
private static buildStateFromOptions;
|
|
10
|
-
private static initializeAuthOptions;
|
|
11
10
|
private static setDefaultRoutes;
|
|
12
11
|
}
|
|
@@ -37,7 +37,7 @@ let DynamicApiModule = DynamicApiModule_1 = class DynamicApiModule {
|
|
|
37
37
|
cache_manager_1.CacheModule.register({ isGlobal: true, ...cacheOptions }),
|
|
38
38
|
mongoose_1.MongooseModule.forRoot(uri, { connectionName: this.state.get('connectionName') }),
|
|
39
39
|
...(useAuth?.userEntity ? [
|
|
40
|
-
modules_1.AuthModule.forRoot(
|
|
40
|
+
modules_1.AuthModule.forRoot(useAuth),
|
|
41
41
|
] : []),
|
|
42
42
|
],
|
|
43
43
|
exports: [modules_1.DynamicApiConfigModule],
|
|
@@ -139,32 +139,6 @@ let DynamicApiModule = DynamicApiModule_1 = class DynamicApiModule {
|
|
|
139
139
|
} : {}),
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
static initializeAuthOptions(useAuth) {
|
|
143
|
-
return {
|
|
144
|
-
userEntity: useAuth.userEntity,
|
|
145
|
-
login: {
|
|
146
|
-
...useAuth.login,
|
|
147
|
-
loginField: useAuth.login?.loginField ?? 'email',
|
|
148
|
-
passwordField: useAuth.login?.passwordField ?? 'password',
|
|
149
|
-
additionalFields: useAuth.login?.additionalFields ?? [],
|
|
150
|
-
},
|
|
151
|
-
register: {
|
|
152
|
-
...useAuth.register,
|
|
153
|
-
additionalFields: useAuth.register?.additionalFields ?? [],
|
|
154
|
-
protected: useAuth.register?.protected ?? !!useAuth.register.abilityPredicate,
|
|
155
|
-
},
|
|
156
|
-
resetPassword: {
|
|
157
|
-
...useAuth.resetPassword,
|
|
158
|
-
emailField: !useAuth.resetPassword?.emailField ? 'email' : String(useAuth.resetPassword.emailField),
|
|
159
|
-
expirationInMinutes: useAuth.resetPassword?.expirationInMinutes ?? 10,
|
|
160
|
-
},
|
|
161
|
-
jwt: {
|
|
162
|
-
secret: useAuth.jwt?.secret ?? 'dynamic-api-jwt-secret',
|
|
163
|
-
expiresIn: useAuth.jwt?.expiresIn ?? '1d',
|
|
164
|
-
},
|
|
165
|
-
validationPipeOptions: useAuth.validationPipeOptions,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
142
|
static setDefaultRoutes(stateRoutesConfig, controllerRoutesConfig = {}, routes = []) {
|
|
169
143
|
const defaults = controllerRoutesConfig.defaults ?? stateRoutesConfig.defaults;
|
|
170
144
|
const excluded = controllerRoutesConfig.excluded ?? stateRoutesConfig.excluded;
|
|
@@ -3,10 +3,11 @@ import { BcryptService } from '../../services';
|
|
|
3
3
|
import { DynamicApiAuthOptions } from './interfaces';
|
|
4
4
|
import { JwtStrategy } from './strategies';
|
|
5
5
|
export declare class AuthModule {
|
|
6
|
-
static forRoot<Entity extends BaseEntity>(
|
|
6
|
+
static forRoot<Entity extends BaseEntity>(options: DynamicApiAuthOptions<Entity>, extraImports?: any[]): {
|
|
7
7
|
module: typeof AuthModule;
|
|
8
8
|
imports: any[];
|
|
9
9
|
providers: (typeof BcryptService | import("../../interfaces/dynamic-api-service-provider.interface").DynamicAPIServiceProvider | typeof JwtStrategy)[];
|
|
10
10
|
controllers: import("./interfaces/auth-controller.interface").AuthControllerConstructor<Entity>[];
|
|
11
11
|
};
|
|
12
|
+
private static initializeAuthOptions;
|
|
12
13
|
}
|
|
@@ -18,10 +18,11 @@ const services_1 = require("../../services");
|
|
|
18
18
|
const auth_helper_1 = require("./auth.helper");
|
|
19
19
|
const strategies_1 = require("./strategies");
|
|
20
20
|
let AuthModule = AuthModule_1 = class AuthModule {
|
|
21
|
-
static forRoot(
|
|
22
|
-
const {
|
|
21
|
+
static forRoot(options, extraImports = []) {
|
|
22
|
+
const { userEntity, login: { loginField, passwordField, ...login }, register, resetPassword, jwt: { secret, expiresIn }, validationPipeOptions, } = this.initializeAuthOptions(options);
|
|
23
|
+
const { resetPasswordCallback, changePasswordCallback, emailField, expirationInMinutes, abilityPredicate, } = resetPassword;
|
|
23
24
|
const resetPasswordOptions = resetPasswordCallback
|
|
24
|
-
? { resetPasswordCallback, changePasswordCallback, emailField, expirationInMinutes }
|
|
25
|
+
? { resetPasswordCallback, changePasswordCallback, emailField, expirationInMinutes, abilityPredicate }
|
|
25
26
|
: undefined;
|
|
26
27
|
const AuthController = (0, auth_helper_1.createAuthController)(userEntity, { loginField, passwordField, ...login }, register, validationPipeOptions, resetPasswordOptions);
|
|
27
28
|
const AuthServiceProvider = (0, auth_helper_1.createAuthServiceProvider)(userEntity, { loginField, passwordField, ...login }, register.callback, resetPasswordOptions);
|
|
@@ -52,6 +53,32 @@ let AuthModule = AuthModule_1 = class AuthModule {
|
|
|
52
53
|
controllers: [AuthController],
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
static initializeAuthOptions({ userEntity, login, register, resetPassword, jwt, validationPipeOptions, }) {
|
|
57
|
+
return {
|
|
58
|
+
userEntity: userEntity,
|
|
59
|
+
login: {
|
|
60
|
+
...login,
|
|
61
|
+
loginField: (login?.loginField ?? 'email'),
|
|
62
|
+
passwordField: (login?.passwordField ?? 'password'),
|
|
63
|
+
additionalFields: login?.additionalFields ?? [],
|
|
64
|
+
},
|
|
65
|
+
register: {
|
|
66
|
+
...register,
|
|
67
|
+
additionalFields: register?.additionalFields ?? [],
|
|
68
|
+
protected: register?.protected ?? !!register?.abilityPredicate,
|
|
69
|
+
},
|
|
70
|
+
resetPassword: {
|
|
71
|
+
...resetPassword,
|
|
72
|
+
emailField: (!resetPassword?.emailField ? 'email' : String(resetPassword.emailField)),
|
|
73
|
+
expirationInMinutes: resetPassword?.expirationInMinutes ?? 10,
|
|
74
|
+
},
|
|
75
|
+
jwt: {
|
|
76
|
+
secret: jwt?.secret ?? 'dynamic-api-jwt-secret',
|
|
77
|
+
expiresIn: jwt?.expiresIn ?? '1d',
|
|
78
|
+
},
|
|
79
|
+
validationPipeOptions: validationPipeOptions,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
55
82
|
};
|
|
56
83
|
exports.AuthModule = AuthModule;
|
|
57
84
|
exports.AuthModule = AuthModule = AuthModule_1 = __decorate([
|
package/src/version.json
CHANGED