@lenne.tech/nest-server 8.0.0 → 8.0.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/core.module.js +21 -18
- package/dist/core.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core.module.ts +26 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nest-server",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
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",
|
package/src/core.module.ts
CHANGED
|
@@ -43,32 +43,36 @@ export class CoreModule {
|
|
|
43
43
|
driver: {
|
|
44
44
|
imports: [AuthModule],
|
|
45
45
|
inject: [AuthService],
|
|
46
|
-
useFactory: async (authService: any) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
useFactory: async (authService: any) =>
|
|
47
|
+
Object.assign(
|
|
48
|
+
{
|
|
49
|
+
autoSchemaFile: 'schema.gql',
|
|
50
|
+
context: ({ req }) => ({ req }),
|
|
51
|
+
installSubscriptionHandlers: true,
|
|
52
|
+
subscriptions: {
|
|
53
|
+
'subscriptions-transport-ws': {
|
|
54
|
+
onConnect: async (connectionParams) => {
|
|
55
|
+
if (config.graphQl.enableSubscriptionAuth) {
|
|
56
|
+
// get authToken from authorization header
|
|
57
|
+
const authToken: string =
|
|
58
|
+
'Authorization' in connectionParams && connectionParams?.Authorization?.split(' ')[1];
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if (authToken) {
|
|
61
|
+
// verify authToken/getJwtPayLoad
|
|
62
|
+
const payload = authService.decodeJwt(authToken);
|
|
63
|
+
const user = await authService.validateUser(payload);
|
|
64
|
+
// the user/jwtPayload object found will be available as context.currentUser/jwtPayload in your GraphQL resolvers
|
|
65
|
+
return { user: user, headers: connectionParams };
|
|
66
|
+
}
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
throw new UnauthorizedException();
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
68
72
|
},
|
|
69
73
|
},
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
options?.graphQl?.driver
|
|
75
|
+
),
|
|
72
76
|
},
|
|
73
77
|
enableSubscriptionAuth: true,
|
|
74
78
|
},
|