@mondomob/gae-node-nestjs 9.0.0 → 9.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.
@@ -0,0 +1,41 @@
1
+ import { Inject, Injectable } from '@nestjs/common';
2
+ import { Configuration } from '../configuration';
3
+ import { Bucket, StorageOptions, Storage } from '@google-cloud/storage';
4
+ import { createLogger, Logger } from './logging';
5
+
6
+ @Injectable()
7
+ export class StorageProvider {
8
+ private readonly _storage: Storage;
9
+ private readonly _defaultBucket: Bucket;
10
+ private readonly logger: Logger;
11
+
12
+ constructor(@Inject('Configuration') private readonly configurationProvider: Configuration) {
13
+ this.logger = createLogger('storage');
14
+ const config: StorageOptions = {};
15
+ if (configurationProvider.isDevelopment()) {
16
+ this.logger.info(
17
+ 'Application is running locally, using keyfile.json credentials to connect to Google Cloud Storage',
18
+ );
19
+ config.keyFilename = './keyfile.json';
20
+ }
21
+ this._storage = new Storage(config);
22
+ this.logger.info(`Default Google Cloud Storage bucket: ${configurationProvider.bucket}`);
23
+ this._defaultBucket = this.storage.bucket(configurationProvider.bucket);
24
+ }
25
+
26
+ get storage(): Storage {
27
+ return this._storage;
28
+ }
29
+
30
+ get defaultBucket(): Bucket {
31
+ return this._defaultBucket;
32
+ }
33
+
34
+ async getDefaultBucketResumableUploadUrl(fileId: string): Promise<string> {
35
+ const gcsFile = this._defaultBucket.file(fileId);
36
+ const urls = await gcsFile.createResumableUpload({
37
+ origin: this.configurationProvider.host,
38
+ });
39
+ return urls[0];
40
+ }
41
+ }
@@ -0,0 +1,41 @@
1
+ import { Inject, Injectable } from '@nestjs/common';
2
+ // import { Configuration } from '../configuration';
3
+ import { Bucket, StorageOptions, Storage } from '@google-cloud/storage';
4
+ import { createLogger, Logger } from './logging';
5
+
6
+ @Injectable()
7
+ export class StorageProvider {
8
+ private readonly _storage: Storage;
9
+ private readonly _defaultBucket: Bucket;
10
+ private readonly logger: Logger;
11
+
12
+ constructor(@Inject('Configuration') private readonly configurationProvider: Configuration) {
13
+ this.logger = createLogger('storage');
14
+ const config: StorageOptions = {};
15
+ if (configurationProvider.isDevelopment()) {
16
+ this.logger.info(
17
+ 'Application is running locally, using keyfile.json credentials to connect to Google Cloud Storage',
18
+ );
19
+ config.keyFilename = './keyfile.json';
20
+ }
21
+ this._storage = new Storage(config);
22
+ this.logger.info(`Default Google Cloud Storage bucket: ${configurationProvider.bucket}`);
23
+ this._defaultBucket = this.storage.bucket(configurationProvider.bucket);
24
+ }
25
+
26
+ get storage(): Storage {
27
+ return this._storage;
28
+ }
29
+
30
+ get defaultBucket(): Bucket {
31
+ return this._defaultBucket;
32
+ }
33
+
34
+ async getDefaultBucketResumableUploadUrl(fileId: string): Promise<string> {
35
+ const gcsFile = this._defaultBucket.file(fileId);
36
+ const urls = await gcsFile.createResumableUpload({
37
+ origin: this.configurationProvider.host,
38
+ });
39
+ return urls[0];
40
+ }
41
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 9.0.1 (2023-08-17)
2
+
3
+ Minor change in the server-start script to remove use of 'localhost' when starting and listening for start of datastore emulator.
4
+
1
5
  ## 9.0.0 (2021-11-10)
2
6
 
3
7
  - Update to NestJS 8
package/README.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # gae-node-nestjs
2
+ ## New package
3
+ Please note that while this package will have priority fixes for existing projects, our primary focus has moved to
4
+ our [gae-js](https://github.com/mondo-mob/gae-js) libraries.
2
5
 
6
+ While this library offers a lot of utilities and help for using `nestjs`, `graphql`, `datastore` the new libraries offer
7
+ more targeted libraries, with the following benefits:
8
+
9
+ - Not being tied to `nestjs` and easily used in `express`, `cloud functions`, or others of your choosing
10
+ - A library for using `firestore` natively
11
+ - A library for those still using `datastore` mode
12
+ - Other libraries for specifics. Please see the readme for details.
13
+
14
+ A lot of the underlying utilities have been ported across to the new libraries.
15
+
16
+ ## About
3
17
  Node framework using [nestjs](https://nestjs.com/) and integrating with Google App Engine, particularly Google Data Store.
4
18
 
5
19
 
@@ -0,0 +1,36 @@
1
+ import { CredentialRepository } from './auth.repository';
2
+ import { AuthService } from './auth.service';
3
+ import { InviteUserService } from './invite-user.service';
4
+ import { PasswordResetService } from './password-reset.service';
5
+ import { Context, IUser } from '../datastore/context';
6
+ export declare class AuthResolver {
7
+ private readonly credentialsRepository;
8
+ private readonly authService;
9
+ private readonly passwordResetService;
10
+ private readonly inviteUserService;
11
+ constructor(credentialsRepository: CredentialRepository, authService: AuthService, passwordResetService: PasswordResetService, inviteUserService: InviteUserService);
12
+ credentials({ id }: IUser, _args: {}, context: Context): Promise<{
13
+ username: string;
14
+ type: "google" | "saml" | "auth0" | "oidc" | "password";
15
+ } | undefined>;
16
+ me(_req: void, _args: void, context: Context<IUser>): Promise<IUser | undefined>;
17
+ resetPassword(_req: void, { email }: {
18
+ email: string;
19
+ }, context: Context): Promise<void>;
20
+ confirmResetPassword(_req: void, { code, newPassword }: {
21
+ code: string;
22
+ newPassword: string;
23
+ }, context: Context): Promise<void>;
24
+ inviteUser(_req: void, { email, roles }: {
25
+ email: string;
26
+ roles: string[];
27
+ }, context: Context): Promise<string>;
28
+ checkActivationCode(_req: void, { code }: {
29
+ code: string;
30
+ }, context: Context): Promise<string | null>;
31
+ activateAccount(_req: void, { code, name, password }: {
32
+ code: string;
33
+ name: string;
34
+ password: string;
35
+ }, context: Context): Promise<void>;
36
+ }
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthResolver = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const graphql_1 = require("@nestjs/graphql");
6
+ const auth_repository_1 = require("./auth.repository");
7
+ const auth_service_1 = require("./auth.service");
8
+ const auth_guard_1 = require("./auth.guard");
9
+ const invite_user_service_1 = require("./invite-user.service");
10
+ const password_reset_service_1 = require("./password-reset.service");
11
+ let AuthResolver = class AuthResolver {
12
+ constructor(credentialsRepository, authService, passwordResetService, inviteUserService) {
13
+ this.credentialsRepository = credentialsRepository;
14
+ this.authService = authService;
15
+ this.passwordResetService = passwordResetService;
16
+ this.inviteUserService = inviteUserService;
17
+ }
18
+ async credentials({ id }, _args, context) {
19
+ const [maybeCredentials] = await this.credentialsRepository.query(context, {
20
+ filters: {
21
+ userId: id,
22
+ },
23
+ limit: 1,
24
+ });
25
+ if (maybeCredentials && maybeCredentials.length > 0) {
26
+ const credentials = maybeCredentials[0];
27
+ return {
28
+ username: credentials.id,
29
+ type: credentials.type,
30
+ };
31
+ }
32
+ }
33
+ async me(_req, _args, context) {
34
+ if (context.user) {
35
+ return context.user;
36
+ }
37
+ }
38
+ async resetPassword(_req, { email }, context) {
39
+ return await this.passwordResetService.resetPassword(context, email);
40
+ }
41
+ async confirmResetPassword(_req, { code, newPassword }, context) {
42
+ return await this.passwordResetService.confirmResetPassword(context, code, newPassword);
43
+ }
44
+ async inviteUser(_req, { email, roles }, context) {
45
+ const { user: { id }, } = await this.inviteUserService.inviteUser(context, { email, roles });
46
+ return id;
47
+ }
48
+ async checkActivationCode(_req, { code }, context) {
49
+ return this.inviteUserService.checkActivationCode(context, code);
50
+ }
51
+ async activateAccount(_req, { code, name, password }, context) {
52
+ await this.inviteUserService.activateAccount(context, code, name, password);
53
+ }
54
+ };
55
+ tslib_1.__decorate([
56
+ auth_guard_1.Roles('admin'),
57
+ tslib_1.__metadata("design:type", Function),
58
+ tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
59
+ tslib_1.__metadata("design:returntype", Promise)
60
+ ], AuthResolver.prototype, "credentials", null);
61
+ tslib_1.__decorate([
62
+ auth_guard_1.AllowAnonymous(),
63
+ graphql_1.Query('me'),
64
+ tslib_1.__metadata("design:type", Function),
65
+ tslib_1.__metadata("design:paramtypes", [void 0, void 0, Object]),
66
+ tslib_1.__metadata("design:returntype", Promise)
67
+ ], AuthResolver.prototype, "me", null);
68
+ tslib_1.__decorate([
69
+ auth_guard_1.AllowAnonymous(),
70
+ graphql_1.Mutation(),
71
+ tslib_1.__metadata("design:type", Function),
72
+ tslib_1.__metadata("design:paramtypes", [void 0, Object, Object]),
73
+ tslib_1.__metadata("design:returntype", Promise)
74
+ ], AuthResolver.prototype, "resetPassword", null);
75
+ tslib_1.__decorate([
76
+ auth_guard_1.AllowAnonymous(),
77
+ graphql_1.Mutation(),
78
+ tslib_1.__metadata("design:type", Function),
79
+ tslib_1.__metadata("design:paramtypes", [void 0, Object, Object]),
80
+ tslib_1.__metadata("design:returntype", Promise)
81
+ ], AuthResolver.prototype, "confirmResetPassword", null);
82
+ tslib_1.__decorate([
83
+ auth_guard_1.Roles('admin'),
84
+ graphql_1.Mutation(),
85
+ tslib_1.__metadata("design:type", Function),
86
+ tslib_1.__metadata("design:paramtypes", [void 0, Object, Object]),
87
+ tslib_1.__metadata("design:returntype", Promise)
88
+ ], AuthResolver.prototype, "inviteUser", null);
89
+ tslib_1.__decorate([
90
+ auth_guard_1.AllowAnonymous(),
91
+ graphql_1.Query('checkActivationCode'),
92
+ tslib_1.__metadata("design:type", Function),
93
+ tslib_1.__metadata("design:paramtypes", [void 0, Object, Object]),
94
+ tslib_1.__metadata("design:returntype", Promise)
95
+ ], AuthResolver.prototype, "checkActivationCode", null);
96
+ tslib_1.__decorate([
97
+ auth_guard_1.AllowAnonymous(),
98
+ graphql_1.Mutation(),
99
+ tslib_1.__metadata("design:type", Function),
100
+ tslib_1.__metadata("design:paramtypes", [void 0, Object, Object]),
101
+ tslib_1.__metadata("design:returntype", Promise)
102
+ ], AuthResolver.prototype, "activateAccount", null);
103
+ AuthResolver = tslib_1.__decorate([
104
+ graphql_1.Resolver('User'),
105
+ tslib_1.__metadata("design:paramtypes", [auth_repository_1.CredentialRepository,
106
+ auth_service_1.AuthService,
107
+ password_reset_service_1.PasswordResetService,
108
+ invite_user_service_1.InviteUserService])
109
+ ], AuthResolver);
110
+ exports.AuthResolver = AuthResolver;
111
+ //# sourceMappingURL=auth.graphql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.graphql.js","sourceRoot":"","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BAAc,EAAE;IAChB,kBAAQ,EAAE;;;;mDAOV;AAzEU,YAAY;IADxB,kBAAQ,CAAC,MAAM,CAAC;6CAG2B,sCAAoB;QAC9B,0BAAW;QACF,6CAAoB;QACvB,uCAAiB;GAL5C,YAAY,CA0ExB;AA1EY,oCAAY"}
@@ -0,0 +1,21 @@
1
+ type Credentials {
2
+ username: String
3
+ type: String
4
+ }
5
+
6
+ extend type User {
7
+ credentials: Credentials
8
+ }
9
+
10
+ type Mutation {
11
+ signIn(email: String!, password: String!): User
12
+ resetPassword(email: String!): Boolean
13
+ confirmResetPassword(code: String!, newPassword: String!): Boolean
14
+ inviteUser(email: String!, roles: [String!]): String
15
+ activateAccount(code: String!, name: String!, password: String!): Boolean
16
+ }
17
+
18
+ type Query {
19
+ checkActivationCode(code: String!): String
20
+ me: User
21
+ }
package/dist/module.js CHANGED
@@ -85,10 +85,10 @@ GCloudModule = GCloudModule_1 = (0, tslib_1.__decorate)([
85
85
  {
86
86
  provide: mail_sender_1.MAIL_SENDER,
87
87
  useFactory: (config, gmailConfigurer) => {
88
- const disableMailLogger = !!config.devHooks && config.devHooks.disableLocalMailLogger;
88
+ var _a;
89
89
  console.log(`Configuring mail sender with devHooks: `, config.devHooks);
90
90
  let mailSender;
91
- if (config.environment === 'development' && !disableMailLogger) {
91
+ if (config.environment === 'development' && !((_a = config.devHooks) === null || _a === void 0 ? void 0 : _a.disableLocalMailLogger)) {
92
92
  mailSender = new mail_logging_sender_1.MailLoggingSender();
93
93
  }
94
94
  else if (config.auth.smtp && config.auth.smtp.enabled) {
@@ -97,14 +97,16 @@ GCloudModule = GCloudModule_1 = (0, tslib_1.__decorate)([
97
97
  else {
98
98
  mailSender = new gmail_sender_1.GmailSender(gmailConfigurer, config);
99
99
  }
100
- if (config.devHooks && config.devHooks.emailWhitelist) {
101
- mailSender = new mail_whitelist_sender_1.MailWhitelistSender(mailSender, config);
102
- }
103
- if (config.devHooks && config.devHooks.divertEmailTo) {
104
- mailSender = new mail_diverter_1.MailDiverter(mailSender, config);
105
- }
106
- if (config.devHooks && config.devHooks.emailSubjectPrefix) {
107
- mailSender = new mail_subject_sender_1.MailSubjectSender(mailSender, config);
100
+ if (config.devHooks) {
101
+ if (config.devHooks.emailWhitelist) {
102
+ mailSender = new mail_whitelist_sender_1.MailWhitelistSender(mailSender, config);
103
+ }
104
+ if (config.devHooks.divertEmailTo) {
105
+ mailSender = new mail_diverter_1.MailDiverter(mailSender, config);
106
+ }
107
+ if (config.devHooks.emailSubjectPrefix) {
108
+ mailSender = new mail_subject_sender_1.MailSubjectSender(mailSender, config);
109
+ }
108
110
  }
109
111
  return mailSender;
110
112
  },
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAiH;AACjH,uCAAqD;AACrD,4DAAwD;AACxD,4DAAwD;AACxD,wDAAoD;AACpD,kDAA8C;AAC9C,4DAA6G;AAC7G,sDAAkD;AAClD,oEAA+D;AAC/D,oFAA+E;AAC/E,0EAAqE;AAErE,uEAAmE;AACnE,qCAA0C;AAC1C,gEAA4D;AAC5D,uCAA8E;AAC9E,oEAAgE;AAChE,oEAAgE;AAChE,4DAAwD;AACxD,8FAAyF;AACzF,wDAAoD;AACpD,oEAA+D;AAC/D,oDAA6D;AAC7D,yDAAqD;AACrD,4DAAwD;AACxD,wEAAmE;AACnE,oEAA+D;AAC/D,uFAA8G;AAE9G,2EAAiF;AAEjF,sEAAiE;AACjE,gEAA2D;AAwF3D,IAAa,YAAY,oBAAzB,MAAa,YAAY;IACvB,SAAS,CAAC,QAA4B;QACpC,QAAQ,CAAC,KAAK,CAAC,2BAAiB,EAAE,iDAAsB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,OAAgB;QACtC,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,OAAO,EAAE,CAAC,OAAO,CAAC,mBAAmB,EAAE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AAE,kCAAe,CAAC;aAC3C;YACD;gBACE,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,sBAAS;aACpB;SACF;QACD,OAAO,EAAE;YACP,kCAAe;YACf,sCAAiB;YACjB,sCAAoB;YACpB,uDAAyB;YACzB,sCAAoB;YACpB,yCAAuB;YACvB,6CAAoB;YACpB,uCAAiB;YACjB,yBAAW;YACX,8BAAa;SACd;QACD,WAAW,EAAE,CAAC,gCAAc,EAAE,kCAAe,EAAE,yCAAkB,CAAC;KACnE,CAAC;GACW,YAAY,CAsBxB;AAtBY,oCAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondomob/gae-node-nestjs",
3
- "version": "9.0.0",
3
+ "version": "9.0.1",
4
4
  "description": "Google App Engine datastore repositories and graphql setup with nestjs",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -93,7 +93,7 @@
93
93
  "@types/passport-saml": "1.1.3",
94
94
  "@types/uuid": "8.3.1",
95
95
  "chokidar": "3.5.2",
96
- "express": "4.17.1",
96
+ "express": "4.17.3",
97
97
  "jest": "27.3.1",
98
98
  "prettier": "2.4.1",
99
99
  "rxjs": "7.4.0",
package/server-start.js CHANGED
@@ -35,11 +35,7 @@ class BunyanStream {
35
35
  const component = rec.component || rec.name;
36
36
  const service = rec.service ? `/${rec.service}` : '';
37
37
  const componentColor = componentColors[component] || colors.white;
38
- console.log(
39
- `${formattedTime} ${componentColor(component + service)} ${levelColor(
40
- level + ':',
41
- )} ${message}`,
42
- );
38
+ console.log(`${formattedTime} ${componentColor(component + service)} ${levelColor(level + ':')} ${message}`);
43
39
  }
44
40
  }
45
41
 
@@ -47,11 +43,7 @@ const { logger, loggingStream } = setupLogging();
47
43
 
48
44
  const { buildEvents, stopWebpack } = setupWebpack(logger);
49
45
 
50
- const { stopServer, startServer } = setupServer(
51
- logger,
52
- loggingStream,
53
- buildEvents,
54
- );
46
+ const { stopServer, startServer } = setupServer(logger, loggingStream, buildEvents);
55
47
 
56
48
  const { stopDatastore, startDatastore } = setupDatastore(logger, buildEvents);
57
49
  const { startDsui, stopDsui } = setupDsui(logger);
@@ -61,7 +53,7 @@ startDatastore();
61
53
  startDsui();
62
54
 
63
55
  // Handle process stop
64
- process.on('SIGINT', async function() {
56
+ process.on('SIGINT', async function () {
65
57
  logger.info('Caught interrupt signal');
66
58
 
67
59
  await Promise.all([stopWebpack(), stopDatastore(), stopDsui(), stopServer()]);
@@ -71,19 +63,16 @@ process.on('SIGINT', async function() {
71
63
  });
72
64
 
73
65
  // reload server on graphqls or config files change
74
- chokidar.watch(['./src/**/*.graphqls', './config/**/*.json'])
75
- .on('all', (event, path) => {
76
- if (event === 'add') {
77
- console.log('added to watch list:', path);
78
- } else if (event === 'change') {
79
- console.log('file changed:', path);
80
- stopServer()
81
- .then(() => {
82
- startServer();
83
- })
84
- }
85
- });
86
-
66
+ chokidar.watch(['./src/**/*.graphqls', './config/**/*.json']).on('all', (event, path) => {
67
+ if (event === 'add') {
68
+ console.log('added to watch list:', path);
69
+ } else if (event === 'change') {
70
+ console.log('file changed:', path);
71
+ stopServer().then(() => {
72
+ startServer();
73
+ });
74
+ }
75
+ });
87
76
 
88
77
  function setupLogging() {
89
78
  const loggingStream = new BunyanStream();
@@ -216,9 +205,7 @@ function setupServer(logger, loggingStream, buildEvents) {
216
205
 
217
206
  child.once('close', () => {
218
207
  child = undefined;
219
- serverLogger.warn(
220
- 'Server crashed waiting for restart trigger to restart',
221
- );
208
+ serverLogger.warn('Server crashed waiting for restart trigger to restart');
222
209
  buildEvents.removeListener('reload', hotReload);
223
210
  buildEvents.once('reload', startServer);
224
211
  });
@@ -255,7 +242,7 @@ function setupDsui(logger) {
255
242
  let body = '';
256
243
  http.get(
257
244
  {
258
- hostname: 'localhost',
245
+ hostname: '127.0.0.1',
259
246
  port: DATASTORE_PORT,
260
247
  path: '/',
261
248
  agent: false,
@@ -268,13 +255,7 @@ function setupDsui(logger) {
268
255
  if (res.statusCode == 200) {
269
256
  dsuiLogger.info('Datastore emulator is ready, starting DSUI');
270
257
  clearInterval(timeout);
271
- const gcloud = spawn('gcloud', [
272
- 'beta',
273
- 'emulators',
274
- 'datastore',
275
- 'env-init',
276
- '--format=json',
277
- ]);
258
+ const gcloud = spawn('gcloud', ['beta', 'emulators', 'datastore', 'env-init', '--format=json']);
278
259
  gcloud.stdout.on('data', data => {
279
260
  const datastoreConfig = JSON.parse(data);
280
261
  _.forEach(datastoreConfig, (value, key) => {
@@ -326,13 +307,7 @@ function setupDatastore(logger, buildEvents) {
326
307
  let datastore;
327
308
  const startDatastore = () => {
328
309
  datastoreLogger.info('Starting datastore emulator');
329
- datastore = spawn('gcloud', [
330
- 'beta',
331
- 'emulators',
332
- 'datastore',
333
- 'start',
334
- `--host-port=localhost:${DATASTORE_PORT}`,
335
- ]);
310
+ datastore = spawn('gcloud', ['beta', 'emulators', 'datastore', 'start', `--host-port=127.0.0.1:${DATASTORE_PORT}`]);
336
311
 
337
312
  datastore.stdout.on('data', data => {
338
313
  let string = data.toString('utf8');