@xnestjs/storage 1.5.3 → 1.6.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/README.md +4 -0
- package/cjs/{get-connection-options.js → get-storage-config.js} +2 -2
- package/cjs/index.js +1 -1
- package/cjs/storage-core.module.js +3 -3
- package/esm/{get-connection-options.js → get-storage-config.js} +1 -1
- package/esm/index.js +1 -1
- package/esm/storage-core.module.js +3 -3
- package/package.json +1 -1
- package/types/get-storage-config.d.ts +2 -0
- package/types/index.d.cts +1 -1
- package/types/index.d.ts +1 -1
- package/types/get-connection-options.d.ts +0 -2
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ export class MyModule {
|
|
|
72
72
|
The library supports configuration through environment variables. Environment variables below is accepted.
|
|
73
73
|
All environment variables starts with prefix (STORAGE_). This can be configured while registering the module.
|
|
74
74
|
|
|
75
|
+
<--- BEGIN env --->
|
|
76
|
+
|
|
75
77
|
| Environment Variable | Type | Default | Description |
|
|
76
78
|
|----------------------|------|---------|-------------------------------------|
|
|
77
79
|
| STORAGE_PROVIDER | Enum | | Storage Provider `s3` for Amazon S3 |
|
|
@@ -89,3 +91,5 @@ All environment variables starts with prefix (STORAGE_). This can be configured
|
|
|
89
91
|
| STORAGE_S3_PATH_STYLE | Boolean | | |
|
|
90
92
|
| STORAGE_S3_SECRET_KEY | String | | |
|
|
91
93
|
| STORAGE_S3_ACC_ENDPOINT | String | | |
|
|
94
|
+
|
|
95
|
+
<--- END env --->
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getStorageConfig = getStorageConfig;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
6
6
|
const objects_1 = require("@jsopen/objects");
|
|
7
7
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
8
|
-
function
|
|
8
|
+
function getStorageConfig(moduleOptions, prefix = 'STORAGE_') {
|
|
9
9
|
const options = (0, objects_1.clone)(moduleOptions);
|
|
10
10
|
const env = node_process_1.default.env;
|
|
11
11
|
options.provider = options.provider || env[prefix + 'PROVIDER'];
|
package/cjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./get-
|
|
5
|
+
tslib_1.__exportStar(require("./get-storage-config.js"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./services/storage-bucket.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./services/storage-connection.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./storage.module.js"), exports);
|
|
@@ -6,7 +6,7 @@ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
8
8
|
const constants_js_1 = require("./constants.js");
|
|
9
|
-
const
|
|
9
|
+
const get_storage_config_js_1 = require("./get-storage-config.js");
|
|
10
10
|
const s3_storage_connection_js_1 = require("./providers/s3-storage-connection.js");
|
|
11
11
|
const storage_connection_js_1 = require("./services/storage-connection.js");
|
|
12
12
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
@@ -15,7 +15,7 @@ class StorageCoreModule {
|
|
|
15
15
|
* Configures and returns a dynamic module
|
|
16
16
|
*/
|
|
17
17
|
static forRoot(moduleOptions) {
|
|
18
|
-
const connectionOptions = (0,
|
|
18
|
+
const connectionOptions = (0, get_storage_config_js_1.getStorageConfig)(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
19
19
|
return this._createDynamicModule(moduleOptions, {
|
|
20
20
|
global: moduleOptions.global,
|
|
21
21
|
providers: [
|
|
@@ -39,7 +39,7 @@ class StorageCoreModule {
|
|
|
39
39
|
inject: asyncOptions.inject,
|
|
40
40
|
useFactory: async (...args) => {
|
|
41
41
|
const opts = await asyncOptions.useFactory(...args);
|
|
42
|
-
return (0,
|
|
42
|
+
return (0, get_storage_config_js_1.getStorageConfig)(opts, asyncOptions.envPrefix);
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { clone } from '@jsopen/objects';
|
|
3
3
|
import { toBoolean, toInt } from 'putil-varhelpers';
|
|
4
|
-
export function
|
|
4
|
+
export function getStorageConfig(moduleOptions, prefix = 'STORAGE_') {
|
|
5
5
|
const options = clone(moduleOptions);
|
|
6
6
|
const env = process.env;
|
|
7
7
|
options.provider = options.provider || env[prefix + 'PROVIDER'];
|
package/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { Logger } from '@nestjs/common';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import { STORAGE_MODULE_ID, STORAGE_OPTIONS } from './constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getStorageConfig } from './get-storage-config.js';
|
|
6
6
|
import { S3StorageConnection } from './providers/s3-storage-connection.js';
|
|
7
7
|
import { StorageConnection } from './services/storage-connection.js';
|
|
8
8
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
@@ -11,7 +11,7 @@ export class StorageCoreModule {
|
|
|
11
11
|
* Configures and returns a dynamic module
|
|
12
12
|
*/
|
|
13
13
|
static forRoot(moduleOptions) {
|
|
14
|
-
const connectionOptions =
|
|
14
|
+
const connectionOptions = getStorageConfig(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
15
15
|
return this._createDynamicModule(moduleOptions, {
|
|
16
16
|
global: moduleOptions.global,
|
|
17
17
|
providers: [
|
|
@@ -35,7 +35,7 @@ export class StorageCoreModule {
|
|
|
35
35
|
inject: asyncOptions.inject,
|
|
36
36
|
useFactory: async (...args) => {
|
|
37
37
|
const opts = await asyncOptions.useFactory(...args);
|
|
38
|
-
return
|
|
38
|
+
return getStorageConfig(opts, asyncOptions.envPrefix);
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
],
|
package/package.json
CHANGED
package/types/index.d.cts
CHANGED
package/types/index.d.ts
CHANGED