@nestjs/platform-express 11.1.15 → 12.0.0-alpha.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.
Files changed (42) hide show
  1. package/adapters/express-adapter.d.ts +12 -9
  2. package/adapters/express-adapter.js +95 -48
  3. package/adapters/index.d.ts +1 -1
  4. package/adapters/index.js +1 -4
  5. package/adapters/utils/get-body-parser-options.util.d.ts +1 -1
  6. package/adapters/utils/get-body-parser-options.util.js +1 -4
  7. package/index.d.ts +3 -3
  8. package/index.js +3 -6
  9. package/interfaces/index.d.ts +3 -3
  10. package/interfaces/index.js +2 -5
  11. package/interfaces/nest-express-application.interface.d.ts +5 -5
  12. package/interfaces/nest-express-application.interface.js +1 -2
  13. package/interfaces/nest-express-body-parser-options.interface.js +1 -2
  14. package/interfaces/nest-express-body-parser.interface.js +1 -2
  15. package/interfaces/serve-static-options.interface.js +1 -2
  16. package/multer/files.constants.js +1 -4
  17. package/multer/index.d.ts +3 -3
  18. package/multer/index.js +3 -6
  19. package/multer/interceptors/any-files.interceptor.d.ts +2 -2
  20. package/multer/interceptors/any-files.interceptor.js +13 -15
  21. package/multer/interceptors/file-fields.interceptor.d.ts +2 -2
  22. package/multer/interceptors/file-fields.interceptor.js +13 -15
  23. package/multer/interceptors/file.interceptor.d.ts +2 -2
  24. package/multer/interceptors/file.interceptor.js +13 -15
  25. package/multer/interceptors/files.interceptor.d.ts +2 -2
  26. package/multer/interceptors/files.interceptor.js +13 -15
  27. package/multer/interceptors/index.d.ts +5 -5
  28. package/multer/interceptors/index.js +5 -8
  29. package/multer/interceptors/no-files.interceptor.d.ts +2 -2
  30. package/multer/interceptors/no-files.interceptor.js +13 -15
  31. package/multer/interfaces/files-upload-module.interface.d.ts +2 -2
  32. package/multer/interfaces/files-upload-module.interface.js +1 -2
  33. package/multer/interfaces/index.d.ts +1 -1
  34. package/multer/interfaces/index.js +1 -4
  35. package/multer/interfaces/multer-options.interface.js +1 -2
  36. package/multer/multer/multer.constants.js +2 -5
  37. package/multer/multer/multer.utils.js +21 -24
  38. package/multer/multer.constants.js +1 -4
  39. package/multer/multer.module.d.ts +2 -2
  40. package/multer/multer.module.js +17 -20
  41. package/package.json +17 -5
  42. package/tsconfig.build.json +1 -7
@@ -1,15 +1,14 @@
1
- import { RequestMethod, VersioningOptions } from '@nestjs/common';
2
- import { VersionValue } from '@nestjs/common/interfaces';
3
- import { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
4
- import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
5
- import { AbstractHttpAdapter } from '@nestjs/core/adapters/http-adapter';
6
- import * as express from 'express';
1
+ import { type RequestMethod, type VersioningOptions } from '@nestjs/common';
2
+ import express from 'express';
7
3
  import type { Server } from 'http';
8
4
  import * as http from 'http';
9
5
  import * as https from 'https';
10
- import { NestExpressBodyParserOptions } from '../interfaces/nest-express-body-parser-options.interface';
11
- import { NestExpressBodyParserType } from '../interfaces/nest-express-body-parser.interface';
12
- import { ServeStaticOptions } from '../interfaces/serve-static-options.interface';
6
+ import { NestExpressBodyParserOptions } from '../interfaces/nest-express-body-parser-options.interface.js';
7
+ import { NestExpressBodyParserType } from '../interfaces/nest-express-body-parser.interface.js';
8
+ import { ServeStaticOptions } from '../interfaces/serve-static-options.interface.js';
9
+ import { type CorsOptions, type CorsOptionsDelegate, type VersionValue } from '@nestjs/common/internal';
10
+ import type { NestApplicationOptions } from '@nestjs/common';
11
+ import { AbstractHttpAdapter } from '@nestjs/core';
13
12
  type VersionedRoute = <TRequest extends Record<string, any> = any, TResponse = any>(req: TRequest, res: TResponse, next: () => void) => any;
14
13
  /**
15
14
  * @publicApi
@@ -18,6 +17,8 @@ export declare class ExpressAdapter extends AbstractHttpAdapter<http.Server | ht
18
17
  private readonly routerMethodFactory;
19
18
  private readonly logger;
20
19
  private readonly openConnections;
20
+ private readonly registeredPrefixes;
21
+ private isShuttingDown;
21
22
  private onRequestHook?;
22
23
  private onResponseHook?;
23
24
  constructor(instance?: any);
@@ -37,6 +38,7 @@ export declare class ExpressAdapter extends AbstractHttpAdapter<http.Server | ht
37
38
  normalizePath(path: string): string;
38
39
  listen(port: string | number, callback?: () => void): Server;
39
40
  listen(port: string | number, hostname: string, callback?: () => void): Server;
41
+ beforeClose(): void;
40
42
  close(): Promise<unknown> | undefined;
41
43
  set(...args: any[]): any;
42
44
  enable(...args: any[]): any;
@@ -56,6 +58,7 @@ export declare class ExpressAdapter extends AbstractHttpAdapter<http.Server | ht
56
58
  setLocal(key: string, value: any): this;
57
59
  getType(): string;
58
60
  applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute;
61
+ mapException(error: unknown): unknown;
59
62
  private trackOpenConnections;
60
63
  private closeOpenConnections;
61
64
  private isMiddlewareApplied;
@@ -1,26 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExpressAdapter = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
- const http_adapter_1 = require("@nestjs/core/adapters/http-adapter");
7
- const router_method_factory_1 = require("@nestjs/core/helpers/router-method-factory");
8
- const legacy_route_converter_1 = require("@nestjs/core/router/legacy-route-converter");
9
- const cors = require("cors");
10
- const express = require("express");
11
- const http = require("http");
12
- const https = require("https");
13
- const path_to_regexp_1 = require("path-to-regexp");
14
- const get_body_parser_options_util_1 = require("./utils/get-body-parser-options.util");
1
+ import { BadRequestException, HttpStatus, InternalServerErrorException, Logger, StreamableFile, VERSION_NEUTRAL, VersioningType, } from '@nestjs/common';
2
+ import cors from 'cors';
3
+ import express from 'express';
4
+ import * as http from 'http';
5
+ import * as https from 'https';
6
+ import { pathToRegexp } from 'path-to-regexp';
7
+ import { getBodyParserOptions } from './utils/get-body-parser-options.util.js';
8
+ import { isFunction, isNil, isObject, isString, isUndefined, } from '@nestjs/common/internal';
9
+ import { AbstractHttpAdapter } from '@nestjs/core';
10
+ import { RouterMethodFactory, LegacyRouteConverter, } from '@nestjs/core/internal';
15
11
  /**
16
12
  * @publicApi
17
13
  */
18
- class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
14
+ export class ExpressAdapter extends AbstractHttpAdapter {
15
+ routerMethodFactory = new RouterMethodFactory();
16
+ logger = new Logger(ExpressAdapter.name);
17
+ openConnections = new Set();
18
+ registeredPrefixes = new Set();
19
+ isShuttingDown = false;
20
+ onRequestHook;
21
+ onResponseHook;
19
22
  constructor(instance) {
20
23
  super(instance || express());
21
- this.routerMethodFactory = new router_method_factory_1.RouterMethodFactory();
22
- this.logger = new common_1.Logger(ExpressAdapter.name);
23
- this.openConnections = new Set();
24
24
  this.instance.use((req, res, next) => {
25
25
  if (this.onResponseHook) {
26
26
  res.on('finish', () => {
@@ -45,10 +45,10 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
45
45
  if (statusCode) {
46
46
  response.status(statusCode);
47
47
  }
48
- if ((0, shared_utils_1.isNil)(body)) {
48
+ if (isNil(body)) {
49
49
  return response.send();
50
50
  }
51
- if (body instanceof common_1.StreamableFile) {
51
+ if (body instanceof StreamableFile) {
52
52
  const streamHeaders = body.getHeaders();
53
53
  if (response.getHeader('Content-Type') === undefined &&
54
54
  streamHeaders.type !== undefined) {
@@ -73,11 +73,11 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
73
73
  const responseContentType = response.getHeader('Content-Type');
74
74
  if (typeof responseContentType === 'string' &&
75
75
  !responseContentType.startsWith('application/json') &&
76
- body?.statusCode >= common_1.HttpStatus.BAD_REQUEST) {
76
+ body?.statusCode >= HttpStatus.BAD_REQUEST) {
77
77
  this.logger.warn("Content-Type doesn't match Reply body, you might need a custom ExceptionFilter for non-JSON responses");
78
78
  response.setHeader('Content-Type', 'application/json');
79
79
  }
80
- return (0, shared_utils_1.isObject)(body) ? response.json(body) : response.send(String(body));
80
+ return isObject(body) ? response.json(body) : response.send(String(body));
81
81
  }
82
82
  status(response, statusCode) {
83
83
  return response.status(statusCode);
@@ -92,10 +92,32 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
92
92
  return response.redirect(statusCode, url);
93
93
  }
94
94
  setErrorHandler(handler, prefix) {
95
+ if (prefix) {
96
+ const router = express.Router();
97
+ router.use(handler);
98
+ return this.use(prefix, router);
99
+ }
95
100
  return this.use(handler);
96
101
  }
97
102
  setNotFoundHandler(handler, prefix) {
98
- return this.use(handler);
103
+ if (prefix) {
104
+ this.registeredPrefixes.add(prefix);
105
+ const router = express.Router();
106
+ router.all('*path', handler);
107
+ return this.use(prefix, router);
108
+ }
109
+ return this.use((req, res, next) => {
110
+ // When multiple apps share this adapter, a non-prefixed app's 404
111
+ // handler may be registered before a prefixed app's routes. Skip
112
+ // requests whose path belongs to another app's prefix so they can
113
+ // reach the correct route handlers further in the stack.
114
+ for (const registeredPrefix of this.registeredPrefixes) {
115
+ if (req.originalUrl.startsWith(registeredPrefix)) {
116
+ return next();
117
+ }
118
+ }
119
+ return handler(req, res, next);
120
+ });
99
121
  }
100
122
  isHeadersSent(response) {
101
123
  return response.headersSent;
@@ -111,14 +133,14 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
111
133
  }
112
134
  normalizePath(path) {
113
135
  try {
114
- const convertedPath = legacy_route_converter_1.LegacyRouteConverter.tryConvert(path);
136
+ const convertedPath = LegacyRouteConverter.tryConvert(path);
115
137
  // Call "pathToRegexp" to trigger a TypeError if the path is invalid
116
- (0, path_to_regexp_1.pathToRegexp)(convertedPath);
138
+ pathToRegexp(convertedPath);
117
139
  return convertedPath;
118
140
  }
119
141
  catch (e) {
120
142
  if (e instanceof TypeError) {
121
- legacy_route_converter_1.LegacyRouteConverter.printError(path);
143
+ LegacyRouteConverter.printError(path);
122
144
  }
123
145
  throw e;
124
146
  }
@@ -126,7 +148,11 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
126
148
  listen(port, ...args) {
127
149
  return this.httpServer.listen(port, ...args);
128
150
  }
151
+ beforeClose() {
152
+ this.isShuttingDown = true;
153
+ }
129
154
  close() {
155
+ this.isShuttingDown = true;
130
156
  this.closeOpenConnections();
131
157
  if (!this.httpServer) {
132
158
  return undefined;
@@ -172,14 +198,14 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
172
198
  createMiddlewareFactory(requestMethod) {
173
199
  return (path, callback) => {
174
200
  try {
175
- const convertedPath = legacy_route_converter_1.LegacyRouteConverter.tryConvert(path);
201
+ const convertedPath = LegacyRouteConverter.tryConvert(path);
176
202
  return this.routerMethodFactory
177
203
  .get(this.instance, requestMethod)
178
204
  .call(this.instance, convertedPath, callback);
179
205
  }
180
206
  catch (e) {
181
207
  if (e instanceof TypeError) {
182
- legacy_route_converter_1.LegacyRouteConverter.printError(path);
208
+ LegacyRouteConverter.printError(path);
183
209
  }
184
210
  throw e;
185
211
  }
@@ -193,13 +219,24 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
193
219
  else {
194
220
  this.httpServer = http.createServer(this.getInstance());
195
221
  }
222
+ if (options?.return503OnClosing) {
223
+ this.instance.use((req, res, next) => {
224
+ if (this.isShuttingDown) {
225
+ res.set('Connection', 'close');
226
+ res.status(503).send('Service Unavailable');
227
+ }
228
+ else {
229
+ next();
230
+ }
231
+ });
232
+ }
196
233
  if (options?.forceCloseConnections) {
197
234
  this.trackOpenConnections();
198
235
  }
199
236
  }
200
237
  registerParserMiddleware(prefix, rawBody) {
201
- const bodyParserJsonOptions = (0, get_body_parser_options_util_1.getBodyParserOptions)(rawBody);
202
- const bodyParserUrlencodedOptions = (0, get_body_parser_options_util_1.getBodyParserOptions)(rawBody, {
238
+ const bodyParserJsonOptions = getBodyParserOptions(rawBody);
239
+ const bodyParserUrlencodedOptions = getBodyParserOptions(rawBody, {
203
240
  extended: true,
204
241
  });
205
242
  const parserMiddleware = {
@@ -211,7 +248,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
211
248
  .forEach(parserKey => this.use(parserMiddleware[parserKey]));
212
249
  }
213
250
  useBodyParser(type, rawBody, options) {
214
- const parserOptions = (0, get_body_parser_options_util_1.getBodyParserOptions)(rawBody, options);
251
+ const parserOptions = getBodyParserOptions(rawBody, options);
215
252
  const parser = express[type](parserOptions);
216
253
  this.use(parser);
217
254
  return this;
@@ -226,18 +263,18 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
226
263
  applyVersionFilter(handler, version, versioningOptions) {
227
264
  const callNextHandler = (req, res, next) => {
228
265
  if (!next) {
229
- throw new common_1.InternalServerErrorException('HTTP adapter does not support filtering on version');
266
+ throw new InternalServerErrorException('HTTP adapter does not support filtering on version');
230
267
  }
231
268
  return next();
232
269
  };
233
- if (version === common_1.VERSION_NEUTRAL ||
270
+ if (version === VERSION_NEUTRAL ||
234
271
  // URL Versioning is done via the path, so the filter continues forward
235
- versioningOptions.type === common_1.VersioningType.URI) {
272
+ versioningOptions.type === VersioningType.URI) {
236
273
  const handlerForNoVersioning = (req, res, next) => handler(req, res, next);
237
274
  return handlerForNoVersioning;
238
275
  }
239
276
  // Custom Extractor Versioning Handler
240
- if (versioningOptions.type === common_1.VersioningType.CUSTOM) {
277
+ if (versioningOptions.type === VersioningType.CUSTOM) {
241
278
  const handlerForCustomVersioning = (req, res, next) => {
242
279
  const extractedVersion = versioningOptions.extractor(req);
243
280
  if (Array.isArray(version)) {
@@ -245,12 +282,12 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
245
282
  version.filter(v => extractedVersion.includes(v)).length) {
246
283
  return handler(req, res, next);
247
284
  }
248
- if ((0, shared_utils_1.isString)(extractedVersion) &&
285
+ if (isString(extractedVersion) &&
249
286
  version.includes(extractedVersion)) {
250
287
  return handler(req, res, next);
251
288
  }
252
289
  }
253
- else if ((0, shared_utils_1.isString)(version)) {
290
+ else if (isString(version)) {
254
291
  // Known bug here - if there are multiple versions supported across separate
255
292
  // handlers/controllers, we can't select the highest matching handler.
256
293
  // Since this code is evaluated per-handler, then we can't see if the highest
@@ -259,7 +296,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
259
296
  extractedVersion.includes(version)) {
260
297
  return handler(req, res, next);
261
298
  }
262
- if ((0, shared_utils_1.isString)(extractedVersion) && version === extractedVersion) {
299
+ if (isString(extractedVersion) && version === extractedVersion) {
263
300
  return handler(req, res, next);
264
301
  }
265
302
  }
@@ -268,7 +305,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
268
305
  return handlerForCustomVersioning;
269
306
  }
270
307
  // Media Type (Accept Header) Versioning Handler
271
- if (versioningOptions.type === common_1.VersioningType.MEDIA_TYPE) {
308
+ if (versioningOptions.type === VersioningType.MEDIA_TYPE) {
272
309
  const handlerForMediaTypeVersioning = (req, res, next) => {
273
310
  const MEDIA_TYPE_HEADER = 'Accept';
274
311
  const acceptHeaderValue = req.headers?.[MEDIA_TYPE_HEADER] ||
@@ -277,9 +314,9 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
277
314
  ? acceptHeaderValue.split(';')[1]
278
315
  : undefined;
279
316
  // No version was supplied
280
- if ((0, shared_utils_1.isUndefined)(acceptHeaderVersionParameter)) {
317
+ if (isUndefined(acceptHeaderVersionParameter)) {
281
318
  if (Array.isArray(version)) {
282
- if (version.includes(common_1.VERSION_NEUTRAL)) {
319
+ if (version.includes(VERSION_NEUTRAL)) {
283
320
  return handler(req, res, next);
284
321
  }
285
322
  }
@@ -291,7 +328,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
291
328
  return handler(req, res, next);
292
329
  }
293
330
  }
294
- else if ((0, shared_utils_1.isString)(version)) {
331
+ else if (isString(version)) {
295
332
  if (version === headerVersion) {
296
333
  return handler(req, res, next);
297
334
  }
@@ -302,14 +339,14 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
302
339
  return handlerForMediaTypeVersioning;
303
340
  }
304
341
  // Header Versioning Handler
305
- if (versioningOptions.type === common_1.VersioningType.HEADER) {
342
+ if (versioningOptions.type === VersioningType.HEADER) {
306
343
  const handlerForHeaderVersioning = (req, res, next) => {
307
344
  const customHeaderVersionParameter = req.headers?.[versioningOptions.header] ||
308
345
  req.headers?.[versioningOptions.header.toLowerCase()];
309
346
  // No version was supplied
310
- if ((0, shared_utils_1.isUndefined)(customHeaderVersionParameter)) {
347
+ if (isUndefined(customHeaderVersionParameter)) {
311
348
  if (Array.isArray(version)) {
312
- if (version.includes(common_1.VERSION_NEUTRAL)) {
349
+ if (version.includes(VERSION_NEUTRAL)) {
313
350
  return handler(req, res, next);
314
351
  }
315
352
  }
@@ -320,7 +357,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
320
357
  return handler(req, res, next);
321
358
  }
322
359
  }
323
- else if ((0, shared_utils_1.isString)(version)) {
360
+ else if (isString(version)) {
324
361
  if (version === customHeaderVersionParameter) {
325
362
  return handler(req, res, next);
326
363
  }
@@ -332,6 +369,17 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
332
369
  }
333
370
  throw new Error('Unsupported versioning options');
334
371
  }
372
+ mapException(error) {
373
+ switch (true) {
374
+ // SyntaxError is thrown by Express body-parser when given invalid JSON (#422, #430)
375
+ // URIError is thrown by Express when given a path parameter with an invalid percentage
376
+ // encoding, e.g. '%FF' (#8915)
377
+ case error instanceof SyntaxError || error instanceof URIError:
378
+ return new BadRequestException(error.message);
379
+ default:
380
+ return error;
381
+ }
382
+ }
335
383
  trackOpenConnections() {
336
384
  this.httpServer.on('connection', (socket) => {
337
385
  this.openConnections.add(socket);
@@ -348,8 +396,7 @@ class ExpressAdapter extends http_adapter_1.AbstractHttpAdapter {
348
396
  const app = this.getInstance();
349
397
  return (!!app.router &&
350
398
  !!app.router.stack &&
351
- (0, shared_utils_1.isFunction)(app.router.stack.filter) &&
399
+ isFunction(app.router.stack.filter) &&
352
400
  app.router.stack.some((layer) => layer && layer.handle && layer.handle.name === name));
353
401
  }
354
402
  }
355
- exports.ExpressAdapter = ExpressAdapter;
@@ -1 +1 @@
1
- export * from './express-adapter';
1
+ export * from './express-adapter.js';
package/adapters/index.js CHANGED
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./express-adapter"), exports);
1
+ export * from './express-adapter.js';
@@ -1,2 +1,2 @@
1
- import type { NestExpressBodyParserOptions } from '../../interfaces';
1
+ import type { NestExpressBodyParserOptions } from '../../interfaces/index.js';
2
2
  export declare function getBodyParserOptions<Options = NestExpressBodyParserOptions>(rawBody: boolean, options?: Omit<Options, 'verify'>): Options;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBodyParserOptions = getBodyParserOptions;
4
1
  const rawBodyParser = (req, _res, buffer) => {
5
2
  if (Buffer.isBuffer(buffer)) {
6
3
  req.rawBody = buffer;
7
4
  }
8
5
  return true;
9
6
  };
10
- function getBodyParserOptions(rawBody, options) {
7
+ export function getBodyParserOptions(rawBody, options) {
11
8
  let parserOptions = (options || {});
12
9
  if (rawBody === true) {
13
10
  parserOptions = {
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './adapters';
2
- export * from './interfaces';
3
- export * from './multer';
1
+ export * from './adapters/index.js';
2
+ export * from './interfaces/index.js';
3
+ export * from './multer/index.js';
package/index.js CHANGED
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  /*
3
2
  * Nest @platform-express
4
3
  * Copyright(c) 2017 - 2025 Kamil Mysliwiec
5
4
  * https://nestjs.com
6
5
  * MIT Licensed
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const tslib_1 = require("tslib");
10
- tslib_1.__exportStar(require("./adapters"), exports);
11
- tslib_1.__exportStar(require("./interfaces"), exports);
12
- tslib_1.__exportStar(require("./multer"), exports);
7
+ export * from './adapters/index.js';
8
+ export * from './interfaces/index.js';
9
+ export * from './multer/index.js';
@@ -1,3 +1,3 @@
1
- export * from './nest-express-application.interface';
2
- export { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface';
3
- export * from './nest-express-body-parser.interface';
1
+ export * from './nest-express-application.interface.js';
2
+ export { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface.js';
3
+ export * from './nest-express-body-parser.interface.js';
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./nest-express-application.interface"), exports);
5
- tslib_1.__exportStar(require("./nest-express-body-parser.interface"), exports);
1
+ export * from './nest-express-application.interface.js';
2
+ export * from './nest-express-body-parser.interface.js';
@@ -1,11 +1,11 @@
1
- import { HttpServer, INestApplication } from '@nestjs/common';
2
- import type { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/interfaces/external/cors-options.interface';
1
+ import type { HttpServer, INestApplication } from '@nestjs/common';
3
2
  import type { Express } from 'express';
4
3
  import type { Server as CoreHttpServer } from 'http';
5
4
  import type { Server as CoreHttpsServer } from 'https';
6
- import { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface';
7
- import { NestExpressBodyParserType } from './nest-express-body-parser.interface';
8
- import { ServeStaticOptions } from './serve-static-options.interface';
5
+ import { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface.js';
6
+ import { NestExpressBodyParserType } from './nest-express-body-parser.interface.js';
7
+ import { ServeStaticOptions } from './serve-static-options.interface.js';
8
+ import type { CorsOptions, CorsOptionsDelegate } from '@nestjs/common/internal';
9
9
  /**
10
10
  * Interface describing methods on NestExpressApplication.
11
11
  *
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MULTER_MODULE_OPTIONS = void 0;
4
- exports.MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS';
1
+ export const MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS';
package/multer/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './interceptors';
2
- export * from './interfaces';
3
- export * from './multer.module';
1
+ export * from './interceptors/index.js';
2
+ export * from './interfaces/index.js';
3
+ export * from './multer.module.js';
package/multer/index.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./interceptors"), exports);
5
- tslib_1.__exportStar(require("./interfaces"), exports);
6
- tslib_1.__exportStar(require("./multer.module"), exports);
1
+ export * from './interceptors/index.js';
2
+ export * from './interfaces/index.js';
3
+ export * from './multer.module.js';
@@ -1,5 +1,5 @@
1
- import { NestInterceptor, Type } from '@nestjs/common';
2
- import { MulterOptions } from '../interfaces/multer-options.interface';
1
+ import { type NestInterceptor, type Type } from '@nestjs/common';
2
+ import { MulterOptions } from '../interfaces/multer-options.interface.js';
3
3
  /**
4
4
  * @param localOptions
5
5
  *
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnyFilesInterceptor = AnyFilesInterceptor;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const multer = require("multer");
7
- const files_constants_1 = require("../files.constants");
8
- const multer_utils_1 = require("../multer/multer.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Inject, mixin, Optional, } from '@nestjs/common';
3
+ import multer from 'multer';
4
+ import { MULTER_MODULE_OPTIONS } from '../files.constants.js';
5
+ import { transformException } from '../multer/multer.utils.js';
9
6
  /**
10
7
  * @param localOptions
11
8
  *
12
9
  * @publicApi
13
10
  */
14
- function AnyFilesInterceptor(localOptions) {
11
+ export function AnyFilesInterceptor(localOptions) {
15
12
  let MixinInterceptor = class MixinInterceptor {
13
+ multer;
16
14
  constructor(options = {}) {
17
15
  this.multer = multer({
18
16
  ...options,
@@ -23,7 +21,7 @@ function AnyFilesInterceptor(localOptions) {
23
21
  const ctx = context.switchToHttp();
24
22
  await new Promise((resolve, reject) => this.multer.any()(ctx.getRequest(), ctx.getResponse(), (err) => {
25
23
  if (err) {
26
- const error = (0, multer_utils_1.transformException)(err);
24
+ const error = transformException(err);
27
25
  return reject(error);
28
26
  }
29
27
  resolve();
@@ -31,11 +29,11 @@ function AnyFilesInterceptor(localOptions) {
31
29
  return next.handle();
32
30
  }
33
31
  };
34
- MixinInterceptor = tslib_1.__decorate([
35
- tslib_1.__param(0, (0, common_1.Optional)()),
36
- tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
37
- tslib_1.__metadata("design:paramtypes", [Object])
32
+ MixinInterceptor = __decorate([
33
+ __param(0, Optional()),
34
+ __param(0, Inject(MULTER_MODULE_OPTIONS)),
35
+ __metadata("design:paramtypes", [Object])
38
36
  ], MixinInterceptor);
39
- const Interceptor = (0, common_1.mixin)(MixinInterceptor);
37
+ const Interceptor = mixin(MixinInterceptor);
40
38
  return Interceptor;
41
39
  }
@@ -1,5 +1,5 @@
1
- import { NestInterceptor, Type } from '@nestjs/common';
2
- import { MulterField, MulterOptions } from '../interfaces/multer-options.interface';
1
+ import { type NestInterceptor, type Type } from '@nestjs/common';
2
+ import { MulterField, MulterOptions } from '../interfaces/multer-options.interface.js';
3
3
  /**
4
4
  * @param uploadFields
5
5
  * @param localOptions
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileFieldsInterceptor = FileFieldsInterceptor;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const multer = require("multer");
7
- const files_constants_1 = require("../files.constants");
8
- const multer_utils_1 = require("../multer/multer.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Inject, mixin, Optional, } from '@nestjs/common';
3
+ import multer from 'multer';
4
+ import { MULTER_MODULE_OPTIONS } from '../files.constants.js';
5
+ import { transformException } from '../multer/multer.utils.js';
9
6
  /**
10
7
  * @param uploadFields
11
8
  * @param localOptions
12
9
  * @publicApi
13
10
  */
14
- function FileFieldsInterceptor(uploadFields, localOptions) {
11
+ export function FileFieldsInterceptor(uploadFields, localOptions) {
15
12
  let MixinInterceptor = class MixinInterceptor {
13
+ multer;
16
14
  constructor(options = {}) {
17
15
  this.multer = multer({
18
16
  ...options,
@@ -23,7 +21,7 @@ function FileFieldsInterceptor(uploadFields, localOptions) {
23
21
  const ctx = context.switchToHttp();
24
22
  await new Promise((resolve, reject) => this.multer.fields(uploadFields)(ctx.getRequest(), ctx.getResponse(), (err) => {
25
23
  if (err) {
26
- const error = (0, multer_utils_1.transformException)(err);
24
+ const error = transformException(err);
27
25
  return reject(error);
28
26
  }
29
27
  resolve();
@@ -31,11 +29,11 @@ function FileFieldsInterceptor(uploadFields, localOptions) {
31
29
  return next.handle();
32
30
  }
33
31
  };
34
- MixinInterceptor = tslib_1.__decorate([
35
- tslib_1.__param(0, (0, common_1.Optional)()),
36
- tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
37
- tslib_1.__metadata("design:paramtypes", [Object])
32
+ MixinInterceptor = __decorate([
33
+ __param(0, Optional()),
34
+ __param(0, Inject(MULTER_MODULE_OPTIONS)),
35
+ __metadata("design:paramtypes", [Object])
38
36
  ], MixinInterceptor);
39
- const Interceptor = (0, common_1.mixin)(MixinInterceptor);
37
+ const Interceptor = mixin(MixinInterceptor);
40
38
  return Interceptor;
41
39
  }
@@ -1,5 +1,5 @@
1
- import { NestInterceptor, Type } from '@nestjs/common';
2
- import { MulterOptions } from '../interfaces/multer-options.interface';
1
+ import { type NestInterceptor, type Type } from '@nestjs/common';
2
+ import { MulterOptions } from '../interfaces/multer-options.interface.js';
3
3
  /**
4
4
  * @param fieldName
5
5
  * @param localOptions
@@ -1,19 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileInterceptor = FileInterceptor;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const multer = require("multer");
7
- const files_constants_1 = require("../files.constants");
8
- const multer_utils_1 = require("../multer/multer.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Inject, mixin, Optional, } from '@nestjs/common';
3
+ import multer from 'multer';
4
+ import { MULTER_MODULE_OPTIONS } from '../files.constants.js';
5
+ import { transformException } from '../multer/multer.utils.js';
9
6
  /**
10
7
  * @param fieldName
11
8
  * @param localOptions
12
9
  *
13
10
  * @publicApi
14
11
  */
15
- function FileInterceptor(fieldName, localOptions) {
12
+ export function FileInterceptor(fieldName, localOptions) {
16
13
  let MixinInterceptor = class MixinInterceptor {
14
+ multer;
17
15
  constructor(options = {}) {
18
16
  this.multer = multer({
19
17
  ...options,
@@ -24,7 +22,7 @@ function FileInterceptor(fieldName, localOptions) {
24
22
  const ctx = context.switchToHttp();
25
23
  await new Promise((resolve, reject) => this.multer.single(fieldName)(ctx.getRequest(), ctx.getResponse(), (err) => {
26
24
  if (err) {
27
- const error = (0, multer_utils_1.transformException)(err);
25
+ const error = transformException(err);
28
26
  return reject(error);
29
27
  }
30
28
  resolve();
@@ -32,11 +30,11 @@ function FileInterceptor(fieldName, localOptions) {
32
30
  return next.handle();
33
31
  }
34
32
  };
35
- MixinInterceptor = tslib_1.__decorate([
36
- tslib_1.__param(0, (0, common_1.Optional)()),
37
- tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
38
- tslib_1.__metadata("design:paramtypes", [Object])
33
+ MixinInterceptor = __decorate([
34
+ __param(0, Optional()),
35
+ __param(0, Inject(MULTER_MODULE_OPTIONS)),
36
+ __metadata("design:paramtypes", [Object])
39
37
  ], MixinInterceptor);
40
- const Interceptor = (0, common_1.mixin)(MixinInterceptor);
38
+ const Interceptor = mixin(MixinInterceptor);
41
39
  return Interceptor;
42
40
  }
@@ -1,5 +1,5 @@
1
- import { NestInterceptor, Type } from '@nestjs/common';
2
- import { MulterOptions } from '../interfaces/multer-options.interface';
1
+ import { type NestInterceptor, type Type } from '@nestjs/common';
2
+ import { MulterOptions } from '../interfaces/multer-options.interface.js';
3
3
  /**
4
4
  *
5
5
  * @param fieldName
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilesInterceptor = FilesInterceptor;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const multer = require("multer");
7
- const files_constants_1 = require("../files.constants");
8
- const multer_utils_1 = require("../multer/multer.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Inject, mixin, Optional, } from '@nestjs/common';
3
+ import multer from 'multer';
4
+ import { MULTER_MODULE_OPTIONS } from '../files.constants.js';
5
+ import { transformException } from '../multer/multer.utils.js';
9
6
  /**
10
7
  *
11
8
  * @param fieldName
@@ -14,8 +11,9 @@ const multer_utils_1 = require("../multer/multer.utils");
14
11
  *
15
12
  * @publicApi
16
13
  */
17
- function FilesInterceptor(fieldName, maxCount, localOptions) {
14
+ export function FilesInterceptor(fieldName, maxCount, localOptions) {
18
15
  let MixinInterceptor = class MixinInterceptor {
16
+ multer;
19
17
  constructor(options = {}) {
20
18
  this.multer = multer({
21
19
  ...options,
@@ -26,7 +24,7 @@ function FilesInterceptor(fieldName, maxCount, localOptions) {
26
24
  const ctx = context.switchToHttp();
27
25
  await new Promise((resolve, reject) => this.multer.array(fieldName, maxCount)(ctx.getRequest(), ctx.getResponse(), (err) => {
28
26
  if (err) {
29
- const error = (0, multer_utils_1.transformException)(err);
27
+ const error = transformException(err);
30
28
  return reject(error);
31
29
  }
32
30
  resolve();
@@ -34,11 +32,11 @@ function FilesInterceptor(fieldName, maxCount, localOptions) {
34
32
  return next.handle();
35
33
  }
36
34
  };
37
- MixinInterceptor = tslib_1.__decorate([
38
- tslib_1.__param(0, (0, common_1.Optional)()),
39
- tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
40
- tslib_1.__metadata("design:paramtypes", [Object])
35
+ MixinInterceptor = __decorate([
36
+ __param(0, Optional()),
37
+ __param(0, Inject(MULTER_MODULE_OPTIONS)),
38
+ __metadata("design:paramtypes", [Object])
41
39
  ], MixinInterceptor);
42
- const Interceptor = (0, common_1.mixin)(MixinInterceptor);
40
+ const Interceptor = mixin(MixinInterceptor);
43
41
  return Interceptor;
44
42
  }
@@ -1,5 +1,5 @@
1
- export * from './any-files.interceptor';
2
- export * from './file-fields.interceptor';
3
- export * from './file.interceptor';
4
- export * from './files.interceptor';
5
- export * from './no-files.interceptor';
1
+ export * from './any-files.interceptor.js';
2
+ export * from './file-fields.interceptor.js';
3
+ export * from './file.interceptor.js';
4
+ export * from './files.interceptor.js';
5
+ export * from './no-files.interceptor.js';
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./any-files.interceptor"), exports);
5
- tslib_1.__exportStar(require("./file-fields.interceptor"), exports);
6
- tslib_1.__exportStar(require("./file.interceptor"), exports);
7
- tslib_1.__exportStar(require("./files.interceptor"), exports);
8
- tslib_1.__exportStar(require("./no-files.interceptor"), exports);
1
+ export * from './any-files.interceptor.js';
2
+ export * from './file-fields.interceptor.js';
3
+ export * from './file.interceptor.js';
4
+ export * from './files.interceptor.js';
5
+ export * from './no-files.interceptor.js';
@@ -1,5 +1,5 @@
1
- import { NestInterceptor, Type } from '@nestjs/common';
2
- import { MulterOptions } from '../interfaces/multer-options.interface';
1
+ import { type NestInterceptor, type Type } from '@nestjs/common';
2
+ import { MulterOptions } from '../interfaces/multer-options.interface.js';
3
3
  /**
4
4
  *
5
5
  * @param localOptions
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoFilesInterceptor = NoFilesInterceptor;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const multer = require("multer");
7
- const files_constants_1 = require("../files.constants");
8
- const multer_utils_1 = require("../multer/multer.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Inject, mixin, Optional, } from '@nestjs/common';
3
+ import multer from 'multer';
4
+ import { MULTER_MODULE_OPTIONS } from '../files.constants.js';
5
+ import { transformException } from '../multer/multer.utils.js';
9
6
  /**
10
7
  *
11
8
  * @param localOptions
12
9
  * @publicApi
13
10
  */
14
- function NoFilesInterceptor(localOptions) {
11
+ export function NoFilesInterceptor(localOptions) {
15
12
  let MixinInterceptor = class MixinInterceptor {
13
+ multer;
16
14
  constructor(options = {}) {
17
15
  this.multer = multer({
18
16
  ...options,
@@ -23,7 +21,7 @@ function NoFilesInterceptor(localOptions) {
23
21
  const ctx = context.switchToHttp();
24
22
  await new Promise((resolve, reject) => this.multer.none()(ctx.getRequest(), ctx.getResponse(), (err) => {
25
23
  if (err) {
26
- const error = (0, multer_utils_1.transformException)(err);
24
+ const error = transformException(err);
27
25
  return reject(error);
28
26
  }
29
27
  resolve();
@@ -31,11 +29,11 @@ function NoFilesInterceptor(localOptions) {
31
29
  return next.handle();
32
30
  }
33
31
  };
34
- MixinInterceptor = tslib_1.__decorate([
35
- tslib_1.__param(0, (0, common_1.Optional)()),
36
- tslib_1.__param(0, (0, common_1.Inject)(files_constants_1.MULTER_MODULE_OPTIONS)),
37
- tslib_1.__metadata("design:paramtypes", [Object])
32
+ MixinInterceptor = __decorate([
33
+ __param(0, Optional()),
34
+ __param(0, Inject(MULTER_MODULE_OPTIONS)),
35
+ __metadata("design:paramtypes", [Object])
38
36
  ], MixinInterceptor);
39
- const Interceptor = (0, common_1.mixin)(MixinInterceptor);
37
+ const Interceptor = mixin(MixinInterceptor);
40
38
  return Interceptor;
41
39
  }
@@ -1,5 +1,5 @@
1
- import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
2
- import { MulterOptions } from './multer-options.interface';
1
+ import { MulterOptions } from './multer-options.interface.js';
2
+ import type { ModuleMetadata, Type } from '@nestjs/common';
3
3
  export type MulterModuleOptions = MulterOptions;
4
4
  /**
5
5
  * @publicApi
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1 +1 @@
1
- export * from './files-upload-module.interface';
1
+ export * from './files-upload-module.interface.js';
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./files-upload-module.interface"), exports);
1
+ export * from './files-upload-module.interface.js';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.busboyExceptions = exports.multerExceptions = void 0;
4
- exports.multerExceptions = {
1
+ export const multerExceptions = {
5
2
  // from https://github.com/expressjs/multer/blob/master/lib/multer-error.js
6
3
  LIMIT_PART_COUNT: 'Too many parts',
7
4
  LIMIT_FILE_SIZE: 'File too large',
@@ -12,7 +9,7 @@ exports.multerExceptions = {
12
9
  LIMIT_UNEXPECTED_FILE: 'Unexpected field',
13
10
  MISSING_FIELD_NAME: 'Field name missing',
14
11
  };
15
- exports.busboyExceptions = {
12
+ export const busboyExceptions = {
16
13
  // from https://github.com/mscdex/busboy/blob/master/lib/types/multipart.js
17
14
  MULTIPART_BOUNDARY_NOT_FOUND: 'Multipart: Boundary not found',
18
15
  MULTIPART_MALFORMED_PART_HEADER: 'Malformed part header',
@@ -1,34 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformException = transformException;
4
- const common_1 = require("@nestjs/common");
5
- const multer_constants_1 = require("./multer.constants");
1
+ import { BadRequestException, HttpException, PayloadTooLargeException, } from '@nestjs/common';
2
+ import { multerExceptions, busboyExceptions } from './multer.constants.js';
6
3
  // Multer may add in a 'field' property to the error
7
4
  // https://github.com/expressjs/multer/blob/aa42bea6ac7d0cb8fcb279b15a7278cda805dc63/lib/multer-error.js#L19
8
- function transformException(error) {
9
- if (!error || error instanceof common_1.HttpException) {
5
+ export function transformException(error) {
6
+ if (!error || error instanceof HttpException) {
10
7
  return error;
11
8
  }
12
9
  switch (error.message) {
13
- case multer_constants_1.multerExceptions.LIMIT_FILE_SIZE:
14
- return new common_1.PayloadTooLargeException(error.message);
15
- case multer_constants_1.multerExceptions.LIMIT_FILE_COUNT:
16
- case multer_constants_1.multerExceptions.LIMIT_FIELD_KEY:
17
- case multer_constants_1.multerExceptions.LIMIT_FIELD_VALUE:
18
- case multer_constants_1.multerExceptions.LIMIT_FIELD_COUNT:
19
- case multer_constants_1.multerExceptions.LIMIT_UNEXPECTED_FILE:
20
- case multer_constants_1.multerExceptions.LIMIT_PART_COUNT:
21
- case multer_constants_1.multerExceptions.MISSING_FIELD_NAME:
10
+ case multerExceptions.LIMIT_FILE_SIZE:
11
+ return new PayloadTooLargeException(error.message);
12
+ case multerExceptions.LIMIT_FILE_COUNT:
13
+ case multerExceptions.LIMIT_FIELD_KEY:
14
+ case multerExceptions.LIMIT_FIELD_VALUE:
15
+ case multerExceptions.LIMIT_FIELD_COUNT:
16
+ case multerExceptions.LIMIT_UNEXPECTED_FILE:
17
+ case multerExceptions.LIMIT_PART_COUNT:
18
+ case multerExceptions.MISSING_FIELD_NAME:
22
19
  if (error.field) {
23
- return new common_1.BadRequestException(`${error.message} - ${error.field}`);
20
+ return new BadRequestException(`${error.message} - ${error.field}`);
24
21
  }
25
- return new common_1.BadRequestException(error.message);
26
- case multer_constants_1.busboyExceptions.MULTIPART_BOUNDARY_NOT_FOUND:
27
- return new common_1.BadRequestException(error.message);
28
- case multer_constants_1.busboyExceptions.MULTIPART_MALFORMED_PART_HEADER:
29
- case multer_constants_1.busboyExceptions.MULTIPART_UNEXPECTED_END_OF_FORM:
30
- case multer_constants_1.busboyExceptions.MULTIPART_UNEXPECTED_END_OF_FILE:
31
- return new common_1.BadRequestException(`Multipart: ${error.message}`);
22
+ return new BadRequestException(error.message);
23
+ case busboyExceptions.MULTIPART_BOUNDARY_NOT_FOUND:
24
+ return new BadRequestException(error.message);
25
+ case busboyExceptions.MULTIPART_MALFORMED_PART_HEADER:
26
+ case busboyExceptions.MULTIPART_UNEXPECTED_END_OF_FORM:
27
+ case busboyExceptions.MULTIPART_UNEXPECTED_END_OF_FILE:
28
+ return new BadRequestException(`Multipart: ${error.message}`);
32
29
  }
33
30
  return error;
34
31
  }
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MULTER_MODULE_ID = void 0;
4
- exports.MULTER_MODULE_ID = 'MULTER_MODULE_ID';
1
+ export const MULTER_MODULE_ID = 'MULTER_MODULE_ID';
@@ -1,5 +1,5 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { MulterModuleAsyncOptions, MulterModuleOptions } from './interfaces/files-upload-module.interface';
1
+ import { type DynamicModule } from '@nestjs/common';
2
+ import { MulterModuleAsyncOptions, MulterModuleOptions } from './interfaces/files-upload-module.interface.js';
3
3
  /**
4
4
  * @publicApi
5
5
  */
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  var MulterModule_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MulterModule = void 0;
5
- const tslib_1 = require("tslib");
6
- const common_1 = require("@nestjs/common");
7
- const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
8
- const files_constants_1 = require("./files.constants");
9
- const multer_constants_1 = require("./multer.constants");
2
+ import { __decorate } from "tslib";
3
+ import { Module } from '@nestjs/common';
4
+ import { MULTER_MODULE_OPTIONS } from './files.constants.js';
5
+ import { MULTER_MODULE_ID } from './multer.constants.js';
6
+ import { randomStringGenerator } from '@nestjs/common/internal';
10
7
  /**
11
8
  * @publicApi
12
9
  */
@@ -15,13 +12,13 @@ let MulterModule = MulterModule_1 = class MulterModule {
15
12
  return {
16
13
  module: MulterModule_1,
17
14
  providers: [
18
- { provide: files_constants_1.MULTER_MODULE_OPTIONS, useFactory: () => options },
15
+ { provide: MULTER_MODULE_OPTIONS, useFactory: () => options },
19
16
  {
20
- provide: multer_constants_1.MULTER_MODULE_ID,
21
- useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
17
+ provide: MULTER_MODULE_ID,
18
+ useValue: randomStringGenerator(),
22
19
  },
23
20
  ],
24
- exports: [files_constants_1.MULTER_MODULE_OPTIONS],
21
+ exports: [MULTER_MODULE_OPTIONS],
25
22
  };
26
23
  }
27
24
  static registerAsync(options) {
@@ -31,11 +28,11 @@ let MulterModule = MulterModule_1 = class MulterModule {
31
28
  providers: [
32
29
  ...this.createAsyncProviders(options),
33
30
  {
34
- provide: multer_constants_1.MULTER_MODULE_ID,
35
- useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
31
+ provide: MULTER_MODULE_ID,
32
+ useValue: randomStringGenerator(),
36
33
  },
37
34
  ],
38
- exports: [files_constants_1.MULTER_MODULE_OPTIONS],
35
+ exports: [MULTER_MODULE_OPTIONS],
39
36
  };
40
37
  }
41
38
  static createAsyncProviders(options) {
@@ -53,19 +50,19 @@ let MulterModule = MulterModule_1 = class MulterModule {
53
50
  static createAsyncOptionsProvider(options) {
54
51
  if (options.useFactory) {
55
52
  return {
56
- provide: files_constants_1.MULTER_MODULE_OPTIONS,
53
+ provide: MULTER_MODULE_OPTIONS,
57
54
  useFactory: options.useFactory,
58
55
  inject: options.inject || [],
59
56
  };
60
57
  }
61
58
  return {
62
- provide: files_constants_1.MULTER_MODULE_OPTIONS,
59
+ provide: MULTER_MODULE_OPTIONS,
63
60
  useFactory: async (optionsFactory) => optionsFactory.createMulterOptions(),
64
61
  inject: [options.useExisting || options.useClass],
65
62
  };
66
63
  }
67
64
  };
68
- exports.MulterModule = MulterModule;
69
- exports.MulterModule = MulterModule = MulterModule_1 = tslib_1.__decorate([
70
- (0, common_1.Module)({})
65
+ MulterModule = MulterModule_1 = __decorate([
66
+ Module({})
71
67
  ], MulterModule);
68
+ export { MulterModule };
package/package.json CHANGED
@@ -1,9 +1,21 @@
1
1
  {
2
2
  "name": "@nestjs/platform-express",
3
- "version": "11.1.15",
3
+ "version": "12.0.0-alpha.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
7
+ "type": "module",
8
+ "main": "./index.js",
9
+ "exports": {
10
+ ".": "./index.js",
11
+ "./*.js": "./*.js",
12
+ "./*": "./*.js",
13
+ "./adapters": "./adapters/index.js",
14
+ "./interfaces": "./interfaces/index.js",
15
+ "./multer": "./multer/index.js",
16
+ "./multer/interceptors": "./multer/interceptors/index.js",
17
+ "./multer/interfaces": "./multer/interfaces/index.js"
18
+ },
7
19
  "homepage": "https://nestjs.com",
8
20
  "funding": {
9
21
  "type": "opencollective",
@@ -20,17 +32,17 @@
20
32
  "dependencies": {
21
33
  "cors": "2.8.6",
22
34
  "express": "5.2.1",
23
- "multer": "2.1.0",
35
+ "multer": "2.0.2",
24
36
  "path-to-regexp": "8.3.0",
25
37
  "tslib": "2.8.1"
26
38
  },
27
39
  "devDependencies": {
28
- "@nestjs/common": "11.1.15",
29
- "@nestjs/core": "11.1.15"
40
+ "@nestjs/common": "^12.0.0-alpha.0",
41
+ "@nestjs/core": "^12.0.0-alpha.0"
30
42
  },
31
43
  "peerDependencies": {
32
44
  "@nestjs/common": "^11.0.0",
33
45
  "@nestjs/core": "^11.0.0"
34
46
  },
35
- "gitHead": "cb68ac211dc7df39a8bac01cae043c50634ca303"
47
+ "gitHead": "7035ecc828a2a9f752aad188871b1171663a20c2"
36
48
  }
@@ -2,13 +2,7 @@
2
2
  "extends": "../tsconfig.build.json",
3
3
  "compilerOptions": {
4
4
  "outDir": ".",
5
- "rootDir": ".",
6
- "paths": {
7
- "@nestjs/common": ["../common"],
8
- "@nestjs/common/*": ["../common/*"],
9
- "@nestjs/core": ["../core"],
10
- "@nestjs/core/*": ["../core/*"]
11
- }
5
+ "rootDir": "."
12
6
  },
13
7
  "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts"],
14
8
  "references": [