@lenne.tech/nest-server 10.4.0 → 10.4.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/dist/server/modules/user/user.resolver.d.ts +1 -1
- package/dist/server/modules/user/user.resolver.js +11 -11
- package/dist/server/modules/user/user.resolver.js.map +1 -1
- package/dist/test/test.helper.js +27 -5
- package/dist/test/test.helper.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/src/server/modules/user/user.resolver.ts +9 -9
- package/src/test/test.helper.ts +28 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.2",
|
|
4
4
|
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"test:ci": "NODE_ENV=local jest --config jest-e2e.json --ci --forceExit",
|
|
48
48
|
"test:watch": "NODE_ENV=local jest --watch",
|
|
49
49
|
"prepack": "npm run prestart:prod",
|
|
50
|
-
"prepare": "husky install",
|
|
51
50
|
"prepublishOnly": "npm run lint && npm run test:ci",
|
|
52
51
|
"preversion": "npm run lint",
|
|
53
52
|
"watch": "npm-watch"
|
|
@@ -79,15 +79,6 @@ export class UserResolver {
|
|
|
79
79
|
return await this.userService.getVerifiedState(token);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Request new password for user with email
|
|
84
|
-
*/
|
|
85
|
-
@Roles(RoleEnum.S_EVERYONE)
|
|
86
|
-
@Query(() => Boolean, { description: 'Request new password for user with email' })
|
|
87
|
-
async requestPasswordResetMail(@Args('email') email: string): Promise<boolean> {
|
|
88
|
-
return !!(await this.userService.sendPasswordResetMail(email));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
82
|
// ===========================================================================
|
|
92
83
|
// Mutations
|
|
93
84
|
// ===========================================================================
|
|
@@ -128,6 +119,15 @@ export class UserResolver {
|
|
|
128
119
|
return !!(await this.userService.resetPassword(token, password));
|
|
129
120
|
}
|
|
130
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Request new password for user with email
|
|
124
|
+
*/
|
|
125
|
+
@Roles(RoleEnum.S_EVERYONE)
|
|
126
|
+
@Mutation(() => Boolean, { description: 'Request new password for user with email' })
|
|
127
|
+
async requestPasswordResetMail(@Args('email') email: string): Promise<boolean> {
|
|
128
|
+
return !!(await this.userService.sendPasswordResetMail(email));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
131
|
/**
|
|
132
132
|
* Update existing user
|
|
133
133
|
*/
|
package/src/test/test.helper.ts
CHANGED
|
@@ -204,15 +204,19 @@ export class TestHelper {
|
|
|
204
204
|
|
|
205
205
|
// Init
|
|
206
206
|
let query = '';
|
|
207
|
+
let name: string = undefined;
|
|
207
208
|
|
|
208
209
|
// Convert string to TestGraphQLConfig
|
|
209
|
-
if (
|
|
210
|
+
if (
|
|
211
|
+
(typeof graphql === 'string' || graphql instanceof String)
|
|
212
|
+
&& /^(?![a-zA-Z]+$).*$/.test((graphql as string).trim())
|
|
213
|
+
) {
|
|
210
214
|
// Use input as query
|
|
211
|
-
query = graphql as string;
|
|
215
|
+
query = (graphql as string).trim();
|
|
212
216
|
} else {
|
|
213
217
|
// Use input as name
|
|
214
218
|
if (typeof graphql === 'string' || graphql instanceof String) {
|
|
215
|
-
graphql = { name: graphql } as any;
|
|
219
|
+
graphql = { name: (graphql as string).trim() } as any;
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
// Prepare config
|
|
@@ -225,6 +229,7 @@ export class TestHelper {
|
|
|
225
229
|
},
|
|
226
230
|
graphql,
|
|
227
231
|
) as TestGraphQLConfig;
|
|
232
|
+
name = graphql.name;
|
|
228
233
|
|
|
229
234
|
// Init request
|
|
230
235
|
const queryObj = {};
|
|
@@ -248,7 +253,11 @@ export class TestHelper {
|
|
|
248
253
|
}
|
|
249
254
|
|
|
250
255
|
// Create request payload query
|
|
251
|
-
|
|
256
|
+
if (!graphql.fields?.length && !graphql.arguments) {
|
|
257
|
+
query = `${graphql.type} { ${graphql.name} }`;
|
|
258
|
+
} else {
|
|
259
|
+
query = jsonToGraphQLQuery(queryObj, { pretty: true });
|
|
260
|
+
}
|
|
252
261
|
}
|
|
253
262
|
|
|
254
263
|
if ((graphql as TestGraphQLConfig).type === TestGraphQLType.SUBSCRIPTION) {
|
|
@@ -298,7 +307,21 @@ export class TestHelper {
|
|
|
298
307
|
expect(response.headers['content-type']).toMatch('application/json');
|
|
299
308
|
|
|
300
309
|
// return data
|
|
301
|
-
|
|
310
|
+
if (response.body) {
|
|
311
|
+
if (response.body.data) {
|
|
312
|
+
return name ? response.body.data[(graphql as TestGraphQLConfig).name] : response.body.data;
|
|
313
|
+
}
|
|
314
|
+
return response.body;
|
|
315
|
+
}
|
|
316
|
+
if (response.text) {
|
|
317
|
+
if (JSON.parse(response.text).data) {
|
|
318
|
+
return name
|
|
319
|
+
? JSON.parse(response.text).data[(graphql as TestGraphQLConfig).name]
|
|
320
|
+
: JSON.parse(response.text).data;
|
|
321
|
+
}
|
|
322
|
+
return JSON.parse(response.text);
|
|
323
|
+
}
|
|
324
|
+
return undefined;
|
|
302
325
|
}
|
|
303
326
|
|
|
304
327
|
/**
|