@mondomob/gae-node-nestjs 13.0.1 → 13.1.0

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,3 +1,14 @@
1
+ ## 13.1.0 (2026-11-07)
2
+
3
+ `StorageProvider` can now be given service account credentials through configuration, so apps no longer need a `keyfile.json` committed or copied next to the server for **local development**.
4
+
5
+ Set `storage.credentials` to the contents of the key file, either as an object or a JSON string (for example a `SECRET(...)` placeholder your app resolves before the module is created). It is only used when `isDevelopment()` is true. Invalid JSON throws `storage.credentials is not valid JSON` without including the value.
6
+
7
+ Deployed environments (App Engine) are unchanged: they always use the runtime identity (Application Default Credentials). If `storage.credentials` is set there it is ignored and a warning is logged.
8
+
9
+ When `storage.credentials` is not set nothing changes: local development still reads `./keyfile.json`. That `./keyfile.json` fallback is now deprecated.
10
+
11
+
1
12
  ## 13.0.1 (2026-11-06)
2
13
 
3
14
  Fix a memory leak in request scope (`requestScope.enabled: true`). Request scope now uses Node's `AsyncLocalStorage` instead of `cls-hooked`, which is no longer a dependency.
@@ -15,6 +15,9 @@ export interface Configuration {
15
15
  enabled?: boolean;
16
16
  logBundlingEnabled?: boolean;
17
17
  };
18
+ storage?: {
19
+ credentials?: string | Record<string, unknown>;
20
+ };
18
21
  auth: {
19
22
  fake?: {
20
23
  enabled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;AAsFa,QAAA,aAAa,GAAG,eAAe,CAAC"}
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;AAkGa,QAAA,aAAa,GAAG,eAAe,CAAC"}
@@ -9,4 +9,5 @@ export declare class StorageProvider {
9
9
  get storage(): Storage;
10
10
  get defaultBucket(): Bucket;
11
11
  getDefaultBucketResumableUploadUrl(fileId: string): Promise<string>;
12
+ private static parseCredentials;
12
13
  }
@@ -1,18 +1,30 @@
1
1
  "use strict";
2
+ var StorageProvider_1;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.StorageProvider = void 0;
4
5
  const tslib_1 = require("tslib");
5
6
  const common_1 = require("@nestjs/common");
6
7
  const storage_1 = require("@google-cloud/storage");
7
8
  const logging_1 = require("./logging");
8
- let StorageProvider = class StorageProvider {
9
+ let StorageProvider = StorageProvider_1 = class StorageProvider {
9
10
  constructor(configurationProvider) {
11
+ var _a;
10
12
  this.configurationProvider = configurationProvider;
11
13
  this.logger = (0, logging_1.createLogger)('storage');
12
14
  const config = {};
15
+ const credentials = (_a = configurationProvider.storage) === null || _a === void 0 ? void 0 : _a.credentials;
13
16
  if (configurationProvider.isDevelopment()) {
14
- this.logger.info('Application is running locally, using keyfile.json credentials to connect to Google Cloud Storage');
15
- config.keyFilename = './keyfile.json';
17
+ if (credentials) {
18
+ this.logger.info('Application is running locally, using configured storage.credentials to connect to Google Cloud Storage');
19
+ config.credentials = StorageProvider_1.parseCredentials(credentials);
20
+ }
21
+ else {
22
+ this.logger.info('Application is running locally, using keyfile.json credentials to connect to Google Cloud Storage');
23
+ config.keyFilename = './keyfile.json';
24
+ }
25
+ }
26
+ else if (credentials) {
27
+ this.logger.warn('storage.credentials is only used for local development; ignoring it and using the runtime identity');
16
28
  }
17
29
  this._storage = new storage_1.Storage(config);
18
30
  this.logger.info(`Default Google Cloud Storage bucket: ${configurationProvider.bucket}`);
@@ -31,9 +43,20 @@ let StorageProvider = class StorageProvider {
31
43
  });
32
44
  return urls[0];
33
45
  }
46
+ static parseCredentials(credentials) {
47
+ if (typeof credentials !== 'string') {
48
+ return credentials;
49
+ }
50
+ try {
51
+ return JSON.parse(credentials);
52
+ }
53
+ catch (_a) {
54
+ throw new Error('storage.credentials is not valid JSON');
55
+ }
56
+ }
34
57
  };
35
58
  exports.StorageProvider = StorageProvider;
36
- exports.StorageProvider = StorageProvider = tslib_1.__decorate([
59
+ exports.StorageProvider = StorageProvider = StorageProvider_1 = tslib_1.__decorate([
37
60
  (0, common_1.Injectable)(),
38
61
  tslib_1.__param(0, (0, common_1.Inject)('Configuration')),
39
62
  tslib_1.__metadata("design:paramtypes", [Object])
@@ -1 +1 @@
1
- {"version":3,"file":"storage.provider.js","sourceRoot":"","sources":["../../src/gcloud/storage.provider.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AAEpD,mDAAwE;AACxE,uCAAiD;AAG1C,IAAM,eAAe,GAArB,MAAM,eAAe;IAK1B,YAAsD,qBAAoC;QAApC,0BAAqB,GAArB,qBAAqB,CAAe;QACxF,IAAI,CAAC,MAAM,GAAG,IAAA,sBAAY,EAAC,SAAS,CAAC,CAAC;QACtC,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,IAAI,qBAAqB,CAAC,aAAa,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,mGAAmG,CACpG,CAAC;YACF,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAO,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wCAAwC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC;QACzF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,kCAAkC,CAAC,MAAc;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC;YAC/C,MAAM,EAAE,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wCAAwC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC;QACzF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,kCAAkC,CAAC,MAAc;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC;YAC/C,MAAM,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI;SACxC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,WAA6C;QAC3E,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACjC,CAAC;QAAC,WAAM,CAAC;YAEP,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF,CAAA;AA5DY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAME,mBAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;;GALzB,eAAe,CA4D3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondomob/gae-node-nestjs",
3
- "version": "13.0.1",
3
+ "version": "13.1.0",
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",