@expressots/adapter-express 1.8.0 → 1.8.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.
- package/lib/CHANGELOG.md +19 -0
- package/lib/cjs/adapter-express/express-utils/decorators.js +22 -5
- package/lib/cjs/adapter-express/index.js +1 -3
- package/lib/cjs/types/adapter-express/express-utils/decorators.d.ts +16 -3
- package/lib/cjs/types/adapter-express/index.d.ts +1 -1
- package/lib/package.json +2 -2
- package/package.json +2 -2
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [1.8.2](https://github.com/expressots/adapter-express/compare/1.8.1...1.8.2) (2024-08-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* fileupload req and res retrieval ([1bf2465](https://github.com/expressots/adapter-express/commit/1bf246585f3280220f9da96b00f1780f6fe0169d)), closes [#113](https://github.com/expressots/adapter-express/issues/113)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* file upload type validation & args res, req optional ([9ae3af4](https://github.com/expressots/adapter-express/commit/9ae3af4c58b2ee2c3c5d89dcc93101b092299b3a))
|
|
14
|
+
|
|
15
|
+
## [1.8.1](https://github.com/expressots/adapter-express/compare/1.8.0...1.8.1) (2024-08-21)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* remove server env export & update core deps ([38e1afd](https://github.com/expressots/adapter-express/commit/38e1afddbfc5f47cb9e65c3ed560f8a551ff2172))
|
|
21
|
+
|
|
3
22
|
## [1.8.0](https://github.com/expressots/adapter-express/compare/1.7.0...1.8.0) (2024-08-13)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -339,6 +339,18 @@ function convertToType(value, type) {
|
|
|
339
339
|
}
|
|
340
340
|
return value;
|
|
341
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Type guard to check if an object is a Request
|
|
344
|
+
*/
|
|
345
|
+
function isRequest(obj) {
|
|
346
|
+
return (typeof obj === "object" && obj !== null && "method" in obj && "headers" in obj && "url" in obj);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Type guard to check if an object is a Response
|
|
350
|
+
*/
|
|
351
|
+
function isResponse(obj) {
|
|
352
|
+
return (typeof obj === "object" && obj !== null && "status" in obj && "json" in obj && "send" in obj);
|
|
353
|
+
}
|
|
342
354
|
/**
|
|
343
355
|
* File upload decorator to handle file uploads
|
|
344
356
|
* @param options
|
|
@@ -360,17 +372,22 @@ function FileUpload(options, multerOptions) {
|
|
|
360
372
|
}
|
|
361
373
|
return function (target, propertyKey, descriptor) {
|
|
362
374
|
const originalMethod = descriptor.value;
|
|
363
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
364
375
|
descriptor.value = function (...args) {
|
|
365
|
-
const req = args
|
|
366
|
-
const res = args
|
|
367
|
-
// const next = args[2] as NextFunction;
|
|
376
|
+
const req = args.find(isRequest);
|
|
377
|
+
const res = args.find(isResponse);
|
|
368
378
|
const multerMiddleware = getMulterMiddleware(upload, options, method);
|
|
369
379
|
multerMiddleware(req, res, (err) => {
|
|
370
380
|
if (err) {
|
|
371
381
|
return res.status(400).json({ error: err.message });
|
|
372
382
|
}
|
|
373
|
-
|
|
383
|
+
const result = originalMethod.apply(this, args);
|
|
384
|
+
if (res &&
|
|
385
|
+
result &&
|
|
386
|
+
typeof result != "undefined" &&
|
|
387
|
+
!isRequest(result) &&
|
|
388
|
+
!isResponse(result)) {
|
|
389
|
+
return res.send(result);
|
|
390
|
+
}
|
|
374
391
|
});
|
|
375
392
|
};
|
|
376
393
|
};
|
|
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.AppExpress = void 0;
|
|
18
18
|
__exportStar(require("./express-utils"), exports);
|
|
19
19
|
var application_express_1 = require("./application-express");
|
|
20
20
|
Object.defineProperty(exports, "AppExpress", { enumerable: true, get: function () { return application_express_1.AppExpress; } });
|
|
21
|
-
var application_express_types_1 = require("./application-express.types");
|
|
22
|
-
Object.defineProperty(exports, "ServerEnvironment", { enumerable: true, get: function () { return application_express_types_1.ServerEnvironment; } });
|
|
23
21
|
__exportStar(require("./render"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import { PARAMETER_TYPE, HTTP_VERBS_ENUM } from "./constants";
|
|
3
3
|
import type { HandlerDecorator, Middleware } from "./interfaces";
|
|
4
|
+
import { Request } from "express";
|
|
4
5
|
export declare const injectHttpContext: (target: import("inversify/lib/annotation/decorator_utils").DecoratorTarget<unknown>, targetKey?: string | symbol | undefined, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<unknown>) => void;
|
|
5
6
|
/**
|
|
6
7
|
* Controller decorator to define a new controller
|
|
@@ -132,10 +133,16 @@ export declare function getRenderMetadata(target: object, propertyKey: string |
|
|
|
132
133
|
template?: string;
|
|
133
134
|
defaultData?: Record<string, unknown>;
|
|
134
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* Multer storage engine interface
|
|
138
|
+
*/
|
|
135
139
|
export interface StorageEngine {
|
|
136
|
-
_handleFile(req:
|
|
137
|
-
_removeFile(req:
|
|
140
|
+
_handleFile(req: Request, file: MulterFile, callback: (error?: Error | null, info?: Partial<MulterFile>) => void): void;
|
|
141
|
+
_removeFile(req: Request, file: MulterFile, callback: (error: Error | null) => void): void;
|
|
138
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Multer file interface
|
|
145
|
+
*/
|
|
139
146
|
export interface MulterFile {
|
|
140
147
|
fieldname: string;
|
|
141
148
|
originalname: string;
|
|
@@ -147,6 +154,9 @@ export interface MulterFile {
|
|
|
147
154
|
path?: string;
|
|
148
155
|
buffer?: Buffer;
|
|
149
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Multer limits interface
|
|
159
|
+
*/
|
|
150
160
|
export interface MulterLimits {
|
|
151
161
|
fieldNameSize?: number;
|
|
152
162
|
fieldSize?: number;
|
|
@@ -156,6 +166,9 @@ export interface MulterLimits {
|
|
|
156
166
|
parts?: number;
|
|
157
167
|
headerPairs?: number;
|
|
158
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Multer options interface
|
|
171
|
+
*/
|
|
159
172
|
export interface MulterOptions {
|
|
160
173
|
dest?: string;
|
|
161
174
|
storage?: StorageEngine;
|
|
@@ -163,7 +176,7 @@ export interface MulterOptions {
|
|
|
163
176
|
fileFilter?: FileFilter;
|
|
164
177
|
}
|
|
165
178
|
export type FileFilterCallback = (error: Error | null, acceptFile: boolean) => void;
|
|
166
|
-
export type FileFilter = (req:
|
|
179
|
+
export type FileFilter = (req: Request, file: MulterFile, callback: FileFilterCallback) => void;
|
|
167
180
|
type FieldOptions = {
|
|
168
181
|
fieldName: string;
|
|
169
182
|
maxCount?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./express-utils";
|
|
2
2
|
export { AppExpress } from "./application-express";
|
|
3
3
|
export { IWebServerPublic } from "./application-express.interface";
|
|
4
|
-
export { IWebServer, IWebServerConstructor
|
|
4
|
+
export { IWebServer, IWebServerConstructor } from "./application-express.types";
|
|
5
5
|
export * from "./render";
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/adapter-express",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@adapter-express)",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@codecov/vite-plugin": "^0.0.1-beta.6",
|
|
76
76
|
"@commitlint/cli": "19.2.1",
|
|
77
77
|
"@commitlint/config-conventional": "19.2.2",
|
|
78
|
-
"@expressots/core": "2.16.
|
|
78
|
+
"@expressots/core": "2.16.1",
|
|
79
79
|
"@release-it/conventional-changelog": "8.0.1",
|
|
80
80
|
"@types/express": "4.17.21",
|
|
81
81
|
"@types/node": "20.14.10",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/adapter-express",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Expressots - modern, fast, lightweight nodejs web framework (@adapter-express)",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@codecov/vite-plugin": "^0.0.1-beta.6",
|
|
76
76
|
"@commitlint/cli": "19.2.1",
|
|
77
77
|
"@commitlint/config-conventional": "19.2.2",
|
|
78
|
-
"@expressots/core": "2.16.
|
|
78
|
+
"@expressots/core": "2.16.1",
|
|
79
79
|
"@release-it/conventional-changelog": "8.0.1",
|
|
80
80
|
"@types/express": "4.17.21",
|
|
81
81
|
"@types/node": "20.14.10",
|