@xnestjs/storage 1.7.0 → 1.8.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 CHANGED
@@ -22,23 +22,22 @@ import { Module } from '@nestjs/common';
22
22
  import { StorageModule } from '@xnestjs/storage';
23
23
 
24
24
  @Module({
25
- imports: [
26
- StorageModule.forRoot({
27
- useValue: {
28
- provider: 's3',
29
- s3: {
30
- endPoint: 'play.min.io',
31
- port: 9000,
32
- useSSL: true,
33
- accessKey: 'accessKey',
34
- secretKey: 'secretKey',
35
- },
36
- },
37
- }),
38
- ],
25
+ imports: [
26
+ StorageModule.forRoot({
27
+ useValue: {
28
+ provider: 's3',
29
+ s3: {
30
+ endPoint: 'play.min.io',
31
+ port: 9000,
32
+ useSSL: true,
33
+ accessKey: 'accessKey',
34
+ secretKey: 'secretKey',
35
+ },
36
+ },
37
+ }),
38
+ ],
39
39
  })
40
- export class MyModule {
41
- }
40
+ export class MyModule {}
42
41
  ```
43
42
 
44
43
  ### Register async
@@ -51,37 +50,36 @@ import { Module } from '@nestjs/common';
51
50
  import { StorageModule } from '@xnestjs/storage';
52
51
 
53
52
  @Module({
54
- imports: [
55
- StorageModule.forRootAsync({
56
- inject: [ConfigModule],
57
- useFactory: (config: ConfigService) => ({
58
- provider: 's3',
59
- s3: {
60
- endPoint: config.get('S3_ENDPOINT'),
61
- },
62
- }),
63
- }),
64
- ],
53
+ imports: [
54
+ StorageModule.forRootAsync({
55
+ inject: [ConfigModule],
56
+ useFactory: (config: ConfigService) => ({
57
+ provider: 's3',
58
+ s3: {
59
+ endPoint: config.get('S3_ENDPOINT'),
60
+ },
61
+ }),
62
+ }),
63
+ ],
65
64
  })
66
- export class MyModule {
67
- }
65
+ export class MyModule {}
68
66
  ```
69
67
 
70
68
  ## Environment Variables
71
69
 
72
70
  The library supports configuration through environment variables. Environment variables below is accepted.
73
- All environment variables starts with prefix (STORAGE_). This can be configured while registering the module.
71
+ All environment variables starts with prefix (STORAGE\_). This can be configured while registering the module.
74
72
 
75
73
  <--- BEGIN env --->
76
74
 
77
75
  | Environment Variable | Type | Default | Description |
78
- |----------------------|------|---------|-------------------------------------|
76
+ | -------------------- | ---- | ------- | ----------------------------------- |
79
77
  | STORAGE_PROVIDER | Enum | | Storage Provider `s3` for Amazon S3 |
80
78
 
81
79
  ## Amazon S3 Environment Variables
82
80
 
83
81
  | Environment Variable | Type | Default | Description |
84
- |--------------------------|---------|---------|-----------------|
82
+ | ------------------------ | ------- | ------- | --------------- |
85
83
  | STORAGE_S3_ENDPOINT | String | | S3 Endpoint URL |
86
84
  | STORAGE_S3_SECRET_KEY | String | | |
87
85
  | STORAGE_S3_SSL | Boolean | | |
@@ -14,14 +14,20 @@ function getStorageConfig(moduleOptions, prefix = 'STORAGE_') {
14
14
  if (options.provider === 's3') {
15
15
  options.s3 = options.s3 || {};
16
16
  options.s3.endPoint = options.s3.endPoint ?? env[prefix + 'S3_ENDPOINT'];
17
- options.s3.accessKey = options.s3.secretKey ?? env[prefix + 'S3_ACCESS_KEY'];
18
- options.s3.secretKey = options.s3.secretKey ?? env[prefix + 'S3_SECRET_KEY'];
17
+ options.s3.accessKey =
18
+ options.s3.secretKey ?? env[prefix + 'S3_ACCESS_KEY'];
19
+ options.s3.secretKey =
20
+ options.s3.secretKey ?? env[prefix + 'S3_SECRET_KEY'];
19
21
  options.s3.useSSL = options.s3.useSSL ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'S3_SSL']);
20
22
  options.s3.port = options.s3.port ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'S3_PORT']);
21
- options.s3.sessionToken = options.s3.sessionToken ?? env[prefix + 'S3_SESSION_TOKEN'];
22
- options.s3.partSize = options.s3.partSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'S3_PART_SIZE']);
23
- options.s3.pathStyle = options.s3.pathStyle ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'S3_PATH_STYLE']);
24
- options.s3.s3AccelerateEndpoint = options.s3.s3AccelerateEndpoint ?? env[prefix + 'S3_ACC_ENDPOINT'];
23
+ options.s3.sessionToken =
24
+ options.s3.sessionToken ?? env[prefix + 'S3_SESSION_TOKEN'];
25
+ options.s3.partSize =
26
+ options.s3.partSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'S3_PART_SIZE']);
27
+ options.s3.pathStyle =
28
+ options.s3.pathStyle ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'S3_PATH_STYLE']);
29
+ options.s3.s3AccelerateEndpoint =
30
+ options.s3.s3AccelerateEndpoint ?? env[prefix + 'S3_ACC_ENDPOINT'];
25
31
  }
26
32
  else
27
33
  throw new Error(`Unknown Storage provider (${options.provider})`);
@@ -10,7 +10,9 @@ class S3StorageConnection extends storage_connection_js_1.StorageConnection {
10
10
  this.provider = 's3';
11
11
  this.config = config;
12
12
  this._client = new Minio.Client(config);
13
- this._client.setRequestOptions({ rejectUnauthorized: config.rejectUnauthorized });
13
+ this._client.setRequestOptions({
14
+ rejectUnauthorized: config.rejectUnauthorized,
15
+ });
14
16
  }
15
17
  async putObject(bucketName, objectName, source, options) {
16
18
  const meta = options ? updateMetadata(options?.metadata, options) : {};
@@ -65,7 +65,9 @@ class StorageCoreModule {
65
65
  },
66
66
  {
67
67
  provide: common_1.Logger,
68
- useValue: typeof opts.logger === 'string' ? new common_1.Logger(opts.logger) : opts.logger,
68
+ useValue: typeof opts.logger === 'string'
69
+ ? new common_1.Logger(opts.logger)
70
+ : opts.logger,
69
71
  },
70
72
  ];
71
73
  return {
@@ -10,14 +10,20 @@ export function getStorageConfig(moduleOptions, prefix = 'STORAGE_') {
10
10
  if (options.provider === 's3') {
11
11
  options.s3 = options.s3 || {};
12
12
  options.s3.endPoint = options.s3.endPoint ?? env[prefix + 'S3_ENDPOINT'];
13
- options.s3.accessKey = options.s3.secretKey ?? env[prefix + 'S3_ACCESS_KEY'];
14
- options.s3.secretKey = options.s3.secretKey ?? env[prefix + 'S3_SECRET_KEY'];
13
+ options.s3.accessKey =
14
+ options.s3.secretKey ?? env[prefix + 'S3_ACCESS_KEY'];
15
+ options.s3.secretKey =
16
+ options.s3.secretKey ?? env[prefix + 'S3_SECRET_KEY'];
15
17
  options.s3.useSSL = options.s3.useSSL ?? toBoolean(env[prefix + 'S3_SSL']);
16
18
  options.s3.port = options.s3.port ?? toInt(env[prefix + 'S3_PORT']);
17
- options.s3.sessionToken = options.s3.sessionToken ?? env[prefix + 'S3_SESSION_TOKEN'];
18
- options.s3.partSize = options.s3.partSize ?? toInt(env[prefix + 'S3_PART_SIZE']);
19
- options.s3.pathStyle = options.s3.pathStyle ?? toBoolean(env[prefix + 'S3_PATH_STYLE']);
20
- options.s3.s3AccelerateEndpoint = options.s3.s3AccelerateEndpoint ?? env[prefix + 'S3_ACC_ENDPOINT'];
19
+ options.s3.sessionToken =
20
+ options.s3.sessionToken ?? env[prefix + 'S3_SESSION_TOKEN'];
21
+ options.s3.partSize =
22
+ options.s3.partSize ?? toInt(env[prefix + 'S3_PART_SIZE']);
23
+ options.s3.pathStyle =
24
+ options.s3.pathStyle ?? toBoolean(env[prefix + 'S3_PATH_STYLE']);
25
+ options.s3.s3AccelerateEndpoint =
26
+ options.s3.s3AccelerateEndpoint ?? env[prefix + 'S3_ACC_ENDPOINT'];
21
27
  }
22
28
  else
23
29
  throw new Error(`Unknown Storage provider (${options.provider})`);
@@ -6,7 +6,9 @@ export class S3StorageConnection extends StorageConnection {
6
6
  this.provider = 's3';
7
7
  this.config = config;
8
8
  this._client = new Minio.Client(config);
9
- this._client.setRequestOptions({ rejectUnauthorized: config.rejectUnauthorized });
9
+ this._client.setRequestOptions({
10
+ rejectUnauthorized: config.rejectUnauthorized,
11
+ });
10
12
  }
11
13
  async putObject(bucketName, objectName, source, options) {
12
14
  const meta = options ? updateMetadata(options?.metadata, options) : {};
@@ -61,7 +61,9 @@ export class StorageCoreModule {
61
61
  },
62
62
  {
63
63
  provide: Logger,
64
- useValue: typeof opts.logger === 'string' ? new Logger(opts.logger) : opts.logger,
64
+ useValue: typeof opts.logger === 'string'
65
+ ? new Logger(opts.logger)
66
+ : opts.logger,
65
67
  },
66
68
  ];
67
69
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnestjs/storage",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "NestJS extension library for Storage solutions (S3,GS)",
5
5
  "author": "Panates",
6
6
  "license": "MIT",