@flusys/nestjs-storage 8.0.0 → 8.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.
package/fesm/562.js
CHANGED
|
@@ -3,12 +3,11 @@ import * as __rspack_external_path from "path";
|
|
|
3
3
|
import * as __rspack_external_uuid from "uuid";
|
|
4
4
|
import * as __rspack_external_fs from "fs";
|
|
5
5
|
import * as __rspack_external_mime_types_1e2a4730 from "mime-types";
|
|
6
|
-
import * as __rspack_external_passport from "passport";
|
|
7
6
|
import * as __rspack_external_fs_promises_e1851c9c from "fs/promises";
|
|
8
7
|
export const __rspack_esm_id = 562;
|
|
9
8
|
export const __rspack_esm_ids = [562];
|
|
10
9
|
export const __webpack_modules__ = {
|
|
11
|
-
|
|
10
|
+
968(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
12
11
|
|
|
13
12
|
// EXPORTS
|
|
14
13
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -23,10 +22,6 @@ var common_ = __webpack_require__(157);
|
|
|
23
22
|
var external_path_ = __webpack_require__(521);
|
|
24
23
|
;// CONCATENATED MODULE: external "mime-types"
|
|
25
24
|
|
|
26
|
-
;// CONCATENATED MODULE: external "passport"
|
|
27
|
-
|
|
28
|
-
// EXTERNAL MODULE: external "@flusys/nestjs-shared/constants"
|
|
29
|
-
var constants_ = __webpack_require__(140);
|
|
30
25
|
// EXTERNAL MODULE: ./projects/nestjs-storage/src/config/message-keys.ts
|
|
31
26
|
var message_keys = __webpack_require__(450);
|
|
32
27
|
// EXTERNAL MODULE: ./projects/nestjs-storage/src/services/upload.service.ts + 1 modules
|
|
@@ -61,8 +56,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
61
56
|
|
|
62
57
|
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
66
59
|
/** MIME type prefixes that can be displayed inline in browser */ const VIEWABLE_TYPE_PREFIXES = [
|
|
67
60
|
'image/',
|
|
68
61
|
'video/',
|
|
@@ -78,23 +71,8 @@ class FileServeMiddleware {
|
|
|
78
71
|
constructor(uploadService){
|
|
79
72
|
this.uploadService = uploadService;
|
|
80
73
|
}
|
|
81
|
-
async use(req, res,
|
|
82
|
-
await
|
|
83
|
-
__rspack_external_passport["default"].authenticate('jwt', {
|
|
84
|
-
session: false
|
|
85
|
-
}, (err, user)=>{
|
|
86
|
-
if (err || !user) {
|
|
87
|
-
this.sendErrorResponse(res, new common_.UnauthorizedException({
|
|
88
|
-
message: 'Authentication required',
|
|
89
|
-
messageKey: constants_.AUTH_MESSAGES.TOKEN_INVALID
|
|
90
|
-
}));
|
|
91
|
-
resolvePromise();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
req.user = user;
|
|
95
|
-
this.serveFile(req, res).finally(resolvePromise);
|
|
96
|
-
})(req, res, next);
|
|
97
|
-
});
|
|
74
|
+
async use(req, res, _next) {
|
|
75
|
+
await this.serveFile(req, res);
|
|
98
76
|
}
|
|
99
77
|
async serveFile(req, res) {
|
|
100
78
|
try {
|
|
@@ -215,7 +193,7 @@ class FileServeMiddleware {
|
|
|
215
193
|
if (res.headersSent) {
|
|
216
194
|
return;
|
|
217
195
|
}
|
|
218
|
-
const isHttpException = error instanceof common_.NotFoundException || error instanceof common_.BadRequestException
|
|
196
|
+
const isHttpException = error instanceof common_.NotFoundException || error instanceof common_.BadRequestException;
|
|
219
197
|
const response = isHttpException ? error.getResponse() : null;
|
|
220
198
|
const statusCode = isHttpException ? error.getStatus() : 404;
|
|
221
199
|
const message = response?.message ?? 'File not found';
|
|
@@ -226,7 +204,7 @@ class FileServeMiddleware {
|
|
|
226
204
|
message,
|
|
227
205
|
messageKey,
|
|
228
206
|
messageVariables,
|
|
229
|
-
error: statusCode ===
|
|
207
|
+
error: statusCode === 400 ? 'Bad Request' : 'Not Found',
|
|
230
208
|
statusCode
|
|
231
209
|
});
|
|
232
210
|
}
|
|
@@ -263,7 +241,7 @@ __rspack_async_done();
|
|
|
263
241
|
__webpack_require__.a(module, async function (__rspack_load_async_deps, __rspack_async_done) { try {
|
|
264
242
|
/* import */ var _flusys_nestjs_shared_modules__rspack_import_0 = __webpack_require__(236);
|
|
265
243
|
/* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(157);
|
|
266
|
-
/* import */ var _middlewares_index_js__rspack_import_2 = __webpack_require__(
|
|
244
|
+
/* import */ var _middlewares_index_js__rspack_import_2 = __webpack_require__(968);
|
|
267
245
|
/* import */ var _services_index_js__rspack_import_3 = __webpack_require__(148);
|
|
268
246
|
/* import */ var _config_storage_constants_js__rspack_import_9 = __webpack_require__(188);
|
|
269
247
|
/* import */ var _controllers_index_js__rspack_import_4 = __webpack_require__(488);
|
|
@@ -5,7 +5,7 @@ export declare class FileServeMiddleware implements NestMiddleware {
|
|
|
5
5
|
private uploadService;
|
|
6
6
|
private readonly uploadDir;
|
|
7
7
|
constructor(uploadService: UploadService);
|
|
8
|
-
use(req: Request, res: Response,
|
|
8
|
+
use(req: Request, res: Response, _next: NextFunction): Promise<void>;
|
|
9
9
|
private serveFile;
|
|
10
10
|
private extractFilePath;
|
|
11
11
|
private resolveFilePath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-storage",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "Modular storage package with optional AWS S3, Azure Blob, and SFTP providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./fesm/index.js",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
|
-
"@flusys/nestjs-core": "8.0.
|
|
122
|
-
"@flusys/nestjs-shared": "8.0.
|
|
121
|
+
"@flusys/nestjs-core": "8.0.2",
|
|
122
|
+
"@flusys/nestjs-shared": "8.0.2"
|
|
123
123
|
}
|
|
124
124
|
}
|