@sapphire-caitlyn/schema-kit-nest 0.0.1 → 0.0.2

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.
@@ -1,10 +1,12 @@
1
1
  import { ConfigService } from '@nestjs/config';
2
+ import { ContextLogger } from '@sapphire-caitlyn/schema-kit-nest/context-logger.service';
2
3
  /**
3
4
  * Arquivos no bucket privado do Cloud Storage (`GOOGLE_CLOUD_STORAGE_BUCKET`), autenticado por `GOOGLE_APPLICATION_CREDENTIALS`.
4
5
  * O banco guarda o caminho do objeto; o front recebe URLs assinadas de leitura.
5
6
  */
6
7
  export declare class StorageService {
7
8
  private readonly bucket;
9
+ logger: ContextLogger;
8
10
  constructor(config: ConfigService);
9
11
  /** Envia o arquivo para `<prefix>/<uuid>/<nome do arquivo>` e retorna esse caminho */
10
12
  upload(file: File, prefix: string): Promise<string>;
@@ -14,6 +14,7 @@ const common_1 = require("@nestjs/common");
14
14
  const config_1 = require("@nestjs/config");
15
15
  const storage_1 = require("@google-cloud/storage");
16
16
  const crypto_1 = require("crypto");
17
+ const context_logger_service_1 = require("@sapphire-caitlyn/schema-kit-nest/context-logger.service");
17
18
  /** Validade das URLs assinadas devolvidas ao front */
18
19
  const SIGNED_URL_TTL_MS = 60 * 60 * 1000;
19
20
  /**
@@ -22,7 +23,13 @@ const SIGNED_URL_TTL_MS = 60 * 60 * 1000;
22
23
  */
23
24
  let StorageService = class StorageService {
24
25
  bucket;
26
+ logger;
25
27
  constructor(config) {
28
+ this.logger = new context_logger_service_1.ContextLogger();
29
+ if (!config.get('GOOGLE_CLOUD_STORAGE_BUCKET')) {
30
+ this.logger.warn('GOOGLE_CLOUD_STORAGE_BUCKET não configurado. O StorageService não funcionará.');
31
+ return;
32
+ }
26
33
  this.bucket = new storage_1.Storage().bucket(config.getOrThrow('GOOGLE_CLOUD_STORAGE_BUCKET'));
27
34
  }
28
35
  /** Envia o arquivo para `<prefix>/<uuid>/<nome do arquivo>` e retorna esse caminho */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire-caitlyn/schema-kit-nest",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Base NestJS do schema-kit: SchemaService/SchemaController de CRUD, decorators, validators, Pub/Sub, storage e monitoramento",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",