@miguelmorales13/nestkit 0.4.0 → 0.4.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.
@@ -22,6 +22,12 @@ var _common = require('@nestjs/common');
22
22
 
23
23
  // src/media/media.service.ts
24
24
 
25
+
26
+ // src/media/media.options.ts
27
+ var MEDIA_OPTIONS = /* @__PURE__ */ Symbol("MEDIA_OPTIONS");
28
+ var MEDIA_TTL = /* @__PURE__ */ Symbol("MEDIA_TTL");
29
+
30
+ // src/media/media.service.ts
25
31
  var _crypto = require('crypto');
26
32
  var MediaService = class {
27
33
  constructor(ttlMs) {
@@ -29,9 +35,6 @@ var MediaService = class {
29
35
  this.logger = new (0, _common.Logger)(MediaService.name);
30
36
  this.store = /* @__PURE__ */ new Map();
31
37
  }
32
- store_(data, contentType) {
33
- return this.put(data, contentType);
34
- }
35
38
  put(data, contentType) {
36
39
  this.sweep();
37
40
  const id = _crypto.randomUUID.call(void 0, ).replace(/-/g, "");
@@ -57,14 +60,16 @@ var MediaService = class {
57
60
  }
58
61
  };
59
62
  MediaService = exports.MediaService = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
60
- _common.Injectable.call(void 0, )
63
+ _common.Injectable.call(void 0, ),
64
+ _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, MEDIA_TTL))
61
65
  ], MediaService);
62
66
 
63
- // src/media/media.options.ts
64
- var MEDIA_OPTIONS = /* @__PURE__ */ Symbol("MEDIA_OPTIONS");
65
-
66
67
  // src/media/media.controller.ts
67
68
  var MediaController = class {
69
+ // Both dependencies are injected by explicit token, like the rest of this
70
+ // package. The bundler does not emit decorator metadata, so injecting by type
71
+ // alone leaves Nest unable to resolve the constructor at runtime — and the
72
+ // failure only shows when the consuming app boots, never at build time.
68
73
  constructor(media, options) {
69
74
  this.media = media;
70
75
  this.options = options;
@@ -99,6 +104,7 @@ _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
99
104
  ], MediaController.prototype, "serve", 1);
100
105
  MediaController = _chunk2REOCMUDcjs.__decorateClass.call(void 0, [
101
106
  _common.Controller.call(void 0, ),
107
+ _chunk2REOCMUDcjs.__decorateParam.call(void 0, 0, _common.Inject.call(void 0, MediaService)),
102
108
  _chunk2REOCMUDcjs.__decorateParam.call(void 0, 1, _common.Inject.call(void 0, MEDIA_OPTIONS))
103
109
  ], MediaController);
104
110
 
@@ -111,7 +117,8 @@ var MediaModule = class {
111
117
  controllers: [MediaController],
112
118
  providers: [
113
119
  { provide: MEDIA_OPTIONS, useValue: options },
114
- { provide: MediaService, useFactory: () => new MediaService(_nullishCoalesce(options.ttlMs, () => ( ONE_HOUR))) }
120
+ { provide: MEDIA_TTL, useValue: _nullishCoalesce(options.ttlMs, () => ( ONE_HOUR)) },
121
+ MediaService
115
122
  ],
116
123
  exports: [MediaService]
117
124
  };
@@ -124,4 +131,5 @@ MediaModule = exports.MediaModule = _chunk2REOCMUDcjs.__decorateClass.call(void
124
131
 
125
132
 
126
133
 
127
- exports.MEDIA_OPTIONS = MEDIA_OPTIONS; exports.MediaModule = MediaModule; exports.MediaService = MediaService;
134
+
135
+ exports.MEDIA_OPTIONS = MEDIA_OPTIONS; exports.MEDIA_TTL = MEDIA_TTL; exports.MediaModule = MediaModule; exports.MediaService = MediaService;
@@ -1,5 +1,5 @@
1
1
  export { MediaModule } from './media.module.js';
2
2
  export { MediaService } from './media.service.js';
3
- export { MEDIA_OPTIONS } from './media.options.js';
3
+ export { MEDIA_OPTIONS, MEDIA_TTL } from './media.options.js';
4
4
  export type { MediaOptions } from './media.options.js';
5
5
  export type { StoredMedia } from './media.service.js';
@@ -11,7 +11,7 @@ import {
11
11
  Controller,
12
12
  Get,
13
13
  Headers,
14
- Inject,
14
+ Inject as Inject2,
15
15
  NotFoundException,
16
16
  Param,
17
17
  Post,
@@ -21,7 +21,13 @@ import {
21
21
  } from "@nestjs/common";
22
22
 
23
23
  // src/media/media.service.ts
24
- import { Injectable, Logger } from "@nestjs/common";
24
+ import { Inject, Injectable, Logger } from "@nestjs/common";
25
+
26
+ // src/media/media.options.ts
27
+ var MEDIA_OPTIONS = /* @__PURE__ */ Symbol("MEDIA_OPTIONS");
28
+ var MEDIA_TTL = /* @__PURE__ */ Symbol("MEDIA_TTL");
29
+
30
+ // src/media/media.service.ts
25
31
  import { randomUUID } from "crypto";
26
32
  var MediaService = class {
27
33
  constructor(ttlMs) {
@@ -29,9 +35,6 @@ var MediaService = class {
29
35
  this.logger = new Logger(MediaService.name);
30
36
  this.store = /* @__PURE__ */ new Map();
31
37
  }
32
- store_(data, contentType) {
33
- return this.put(data, contentType);
34
- }
35
38
  put(data, contentType) {
36
39
  this.sweep();
37
40
  const id = randomUUID().replace(/-/g, "");
@@ -57,14 +60,16 @@ var MediaService = class {
57
60
  }
58
61
  };
59
62
  MediaService = __decorateClass([
60
- Injectable()
63
+ Injectable(),
64
+ __decorateParam(0, Inject(MEDIA_TTL))
61
65
  ], MediaService);
62
66
 
63
- // src/media/media.options.ts
64
- var MEDIA_OPTIONS = /* @__PURE__ */ Symbol("MEDIA_OPTIONS");
65
-
66
67
  // src/media/media.controller.ts
67
68
  var MediaController = class {
69
+ // Both dependencies are injected by explicit token, like the rest of this
70
+ // package. The bundler does not emit decorator metadata, so injecting by type
71
+ // alone leaves Nest unable to resolve the constructor at runtime — and the
72
+ // failure only shows when the consuming app boots, never at build time.
68
73
  constructor(media, options) {
69
74
  this.media = media;
70
75
  this.options = options;
@@ -99,7 +104,8 @@ __decorateClass([
99
104
  ], MediaController.prototype, "serve", 1);
100
105
  MediaController = __decorateClass([
101
106
  Controller(),
102
- __decorateParam(1, Inject(MEDIA_OPTIONS))
107
+ __decorateParam(0, Inject2(MediaService)),
108
+ __decorateParam(1, Inject2(MEDIA_OPTIONS))
103
109
  ], MediaController);
104
110
 
105
111
  // src/media/media.module.ts
@@ -111,7 +117,8 @@ var MediaModule = class {
111
117
  controllers: [MediaController],
112
118
  providers: [
113
119
  { provide: MEDIA_OPTIONS, useValue: options },
114
- { provide: MediaService, useFactory: () => new MediaService(options.ttlMs ?? ONE_HOUR) }
120
+ { provide: MEDIA_TTL, useValue: options.ttlMs ?? ONE_HOUR },
121
+ MediaService
115
122
  ],
116
123
  exports: [MediaService]
117
124
  };
@@ -122,6 +129,7 @@ MediaModule = __decorateClass([
122
129
  ], MediaModule);
123
130
  export {
124
131
  MEDIA_OPTIONS,
132
+ MEDIA_TTL,
125
133
  MediaModule,
126
134
  MediaService
127
135
  };
@@ -1,4 +1,5 @@
1
1
  export declare const MEDIA_OPTIONS: unique symbol;
2
+ export declare const MEDIA_TTL: unique symbol;
2
3
  export interface MediaOptions {
3
4
  /**
4
5
  * Base URL the generated links point to, **including the global prefix** if
@@ -21,7 +21,6 @@ export declare class MediaService {
21
21
  private readonly logger;
22
22
  private readonly store;
23
23
  constructor(ttlMs: number);
24
- store_(data: Buffer, contentType: string): string;
25
24
  put(data: Buffer, contentType: string): string;
26
25
  get(id: string): StoredMedia | undefined;
27
26
  /** Swept on write, which is the only moment the map can have grown. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miguelmorales13/nestkit",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",