@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "8.0.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",
@@ -43,32 +43,36 @@ export class CoreModule {
43
43
  driver: {
44
44
  imports: [AuthModule],
45
45
  inject: [AuthService],
46
- useFactory: async (authService: any) => ({
47
- autoSchemaFile: 'schema.gql',
48
- context: ({ req }) => ({ req }),
49
- installSubscriptionHandlers: true,
50
- subscriptions: {
51
- 'subscriptions-transport-ws': {
52
- onConnect: async (connectionParams) => {
53
- if (config.graphQl.enableSubscriptionAuth) {
54
- // get authToken from authorization header
55
- const authToken: string =
56
- 'Authorization' in connectionParams && connectionParams?.Authorization?.split(' ')[1];
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
- if (authToken) {
59
- // verify authToken/getJwtPayLoad
60
- const payload = authService.decodeJwt(authToken);
61
- const user = await authService.validateUser(payload);
62
- // the user/jwtPayload object found will be available as context.currentUser/jwtPayload in your GraphQL resolvers
63
- return { user: user, headers: connectionParams };
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
- throw new UnauthorizedException();
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
  },