@kiyasov/platform-hono 1.1.5 → 1.1.7
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/dist/cjs/src/adapters/hono-adapter.d.ts +11 -11
- package/dist/cjs/src/adapters/hono-adapter.js +24 -24
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.d.ts +2 -2
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/any-files-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.d.ts +3 -3
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/file-fields-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/file-interceptor.d.ts +2 -2
- package/dist/cjs/src/multer/interceptors/file-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/file-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/interceptors/files-interceptor.d.ts +2 -2
- package/dist/cjs/src/multer/interceptors/files-interceptor.js +3 -0
- package/dist/cjs/src/multer/interceptors/files-interceptor.js.map +1 -1
- package/dist/cjs/src/multer/multipart/request.js +0 -3
- package/dist/cjs/src/multer/multipart/request.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/adapters/hono-adapter.d.ts +11 -11
- package/dist/esm/src/adapters/hono-adapter.js +35 -35
- package/dist/esm/src/multer/interceptors/any-files-interceptor.d.ts +2 -2
- package/dist/esm/src/multer/interceptors/any-files-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/any-files-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.d.ts +3 -3
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/file-fields-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/file-interceptor.d.ts +2 -2
- package/dist/esm/src/multer/interceptors/file-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/file-interceptor.js.map +1 -1
- package/dist/esm/src/multer/interceptors/files-interceptor.d.ts +2 -2
- package/dist/esm/src/multer/interceptors/files-interceptor.js +8 -5
- package/dist/esm/src/multer/interceptors/files-interceptor.js.map +1 -1
- package/dist/esm/src/multer/multipart/request.js +0 -3
- package/dist/esm/src/multer/multipart/request.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/multer/interceptors/any-files-interceptor.ts +12 -8
- package/src/multer/interceptors/file-fields-interceptor.ts +12 -8
- package/src/multer/interceptors/file-interceptor.ts +12 -8
- package/src/multer/interceptors/files-interceptor.ts +12 -8
- package/src/multer/multipart/request.ts +0 -4
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Server } from
|
|
4
|
-
import { HttpBindings } from
|
|
5
|
-
import { RequestMethod } from
|
|
6
|
-
import { ErrorHandler, NestApplicationOptions, RequestHandler } from
|
|
7
|
-
import { ServeStaticOptions } from
|
|
8
|
-
import { AbstractHttpAdapter } from
|
|
9
|
-
import { Context, HonoRequest } from
|
|
10
|
-
import { Hono } from
|
|
11
|
-
import { RedirectStatusCode, StatusCode } from
|
|
12
|
-
import { Http2SecureServer, Http2Server } from
|
|
13
|
-
import { TypeBodyParser } from
|
|
3
|
+
import { Server } from "node:net";
|
|
4
|
+
import { HttpBindings } from "@hono/node-server";
|
|
5
|
+
import { RequestMethod } from "@nestjs/common";
|
|
6
|
+
import { ErrorHandler, NestApplicationOptions, RequestHandler } from "@nestjs/common/interfaces";
|
|
7
|
+
import { ServeStaticOptions } from "@hono/node-server/serve-static";
|
|
8
|
+
import { AbstractHttpAdapter } from "@nestjs/core/adapters/http-adapter";
|
|
9
|
+
import { Context, HonoRequest } from "hono";
|
|
10
|
+
import { Hono } from "hono";
|
|
11
|
+
import { RedirectStatusCode, StatusCode } from "hono/utils/http-status";
|
|
12
|
+
import { Http2SecureServer, Http2Server } from "http2";
|
|
13
|
+
import { TypeBodyParser } from "../interfaces";
|
|
14
14
|
type HonoHandler = RequestHandler<HonoRequest, Context>;
|
|
15
15
|
type ServerType = Server | Http2Server | Http2SecureServer;
|
|
16
16
|
export declare class HonoAdapter extends AbstractHttpAdapter<ServerType, HonoRequest, Context> {
|
|
@@ -17,8 +17,8 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
17
17
|
super(new hono_1.Hono());
|
|
18
18
|
}
|
|
19
19
|
getRouteAndHandler(pathOrHandler, handler) {
|
|
20
|
-
let path = typeof pathOrHandler ===
|
|
21
|
-
handler = typeof pathOrHandler ===
|
|
20
|
+
let path = typeof pathOrHandler === "function" ? "" : pathOrHandler;
|
|
21
|
+
handler = typeof pathOrHandler === "function" ? pathOrHandler : handler;
|
|
22
22
|
return [path, handler];
|
|
23
23
|
}
|
|
24
24
|
createRouteHandler(routeHandler) {
|
|
@@ -28,8 +28,8 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
send(ctx) {
|
|
31
|
-
const body = ctx.get(
|
|
32
|
-
return typeof body ===
|
|
31
|
+
const body = ctx.get("body");
|
|
32
|
+
return typeof body === "string" ? ctx.text(body) : ctx.json(body);
|
|
33
33
|
}
|
|
34
34
|
get(pathOrHandler, handler) {
|
|
35
35
|
const [routePath, routeHandler] = this.getRouteAndHandler(pathOrHandler, handler);
|
|
@@ -62,13 +62,13 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
62
62
|
async reply(ctx, body, statusCode) {
|
|
63
63
|
if (statusCode)
|
|
64
64
|
ctx.status(statusCode);
|
|
65
|
-
const responseContentType = this.getHeader(ctx,
|
|
66
|
-
if (!responseContentType?.startsWith(
|
|
65
|
+
const responseContentType = this.getHeader(ctx, "Content-Type");
|
|
66
|
+
if (!responseContentType?.startsWith("application/json") &&
|
|
67
67
|
body?.statusCode >= common_2.HttpStatus.BAD_REQUEST) {
|
|
68
68
|
common_2.Logger.warn("Content-Type doesn't match Reply body, you might need a custom ExceptionFilter for non-JSON responses");
|
|
69
|
-
this.setHeader(ctx,
|
|
69
|
+
this.setHeader(ctx, "Content-Type", "application/json");
|
|
70
70
|
}
|
|
71
|
-
ctx.set(
|
|
71
|
+
ctx.set("body", body);
|
|
72
72
|
}
|
|
73
73
|
status(ctx, statusCode) {
|
|
74
74
|
ctx.status(statusCode);
|
|
@@ -77,7 +77,7 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
77
77
|
return response_1.RESPONSE_ALREADY_SENT;
|
|
78
78
|
}
|
|
79
79
|
render(response, view, options) {
|
|
80
|
-
throw new Error(
|
|
80
|
+
throw new Error("Method not implemented.");
|
|
81
81
|
}
|
|
82
82
|
redirect(ctx, statusCode, url) {
|
|
83
83
|
ctx.redirect(url, statusCode);
|
|
@@ -95,11 +95,11 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
useStaticAssets(path, options) {
|
|
98
|
-
common_2.Logger.log(
|
|
98
|
+
common_2.Logger.log("Registering static assets middleware");
|
|
99
99
|
this.instance.use(path, (0, serve_static_1.serveStatic)(options));
|
|
100
100
|
}
|
|
101
101
|
setViewEngine(options) {
|
|
102
|
-
throw new Error(
|
|
102
|
+
throw new Error("Method not implemented.");
|
|
103
103
|
}
|
|
104
104
|
isHeadersSent(ctx) {
|
|
105
105
|
return true;
|
|
@@ -126,16 +126,16 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
126
126
|
this.instance.use((0, cors_1.cors)(options));
|
|
127
127
|
}
|
|
128
128
|
useBodyParser(type, bodyLimit = 1e6) {
|
|
129
|
-
common_2.Logger.log(
|
|
129
|
+
common_2.Logger.log("Registering body parser middleware");
|
|
130
130
|
this.instance.use(this.bodyLimit(bodyLimit), async (ctx, next) => {
|
|
131
|
-
const contentType = ctx.req.header(
|
|
131
|
+
const contentType = ctx.req.header("content-type");
|
|
132
132
|
switch (type) {
|
|
133
|
-
case
|
|
134
|
-
if (contentType ===
|
|
133
|
+
case "application/json":
|
|
134
|
+
if (contentType === "application/json")
|
|
135
135
|
ctx.req.body = await ctx.req.json();
|
|
136
136
|
break;
|
|
137
|
-
case
|
|
138
|
-
if (contentType ===
|
|
137
|
+
case "text/plain":
|
|
138
|
+
if (contentType === "text/plain") {
|
|
139
139
|
ctx.req.rawBody = Buffer.from(await ctx.req.text());
|
|
140
140
|
ctx.req.body = await ctx.req.json();
|
|
141
141
|
}
|
|
@@ -162,13 +162,13 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
getType() {
|
|
165
|
-
return
|
|
165
|
+
return "hono";
|
|
166
166
|
}
|
|
167
167
|
registerParserMiddleware(prefix, rawBody) {
|
|
168
|
-
common_2.Logger.log(
|
|
169
|
-
this.useBodyParser(
|
|
170
|
-
this.useBodyParser(
|
|
171
|
-
this.useBodyParser(
|
|
168
|
+
common_2.Logger.log("Registering parser middleware");
|
|
169
|
+
this.useBodyParser("application/x-www-form-urlencoded");
|
|
170
|
+
this.useBodyParser("application/json");
|
|
171
|
+
this.useBodyParser("text/plain");
|
|
172
172
|
}
|
|
173
173
|
async createMiddlewareFactory(requestMethod) {
|
|
174
174
|
return (path, callback) => {
|
|
@@ -188,7 +188,7 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
applyVersionFilter() {
|
|
191
|
-
throw new Error(
|
|
191
|
+
throw new Error("Versioning not yet supported in Hono");
|
|
192
192
|
}
|
|
193
193
|
listen(port, ...args) {
|
|
194
194
|
return this.httpServer.listen(port, ...args);
|
|
@@ -197,7 +197,7 @@ class HonoAdapter extends http_adapter_1.AbstractHttpAdapter {
|
|
|
197
197
|
return (0, body_limit_1.bodyLimit)({
|
|
198
198
|
maxSize,
|
|
199
199
|
onError: () => {
|
|
200
|
-
throw new Error(
|
|
200
|
+
throw new Error("Body too large");
|
|
201
201
|
},
|
|
202
202
|
});
|
|
203
203
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NestInterceptor, Type } from
|
|
2
|
-
import { UploadOptions } from
|
|
1
|
+
import { NestInterceptor, Type } from "@nestjs/common";
|
|
2
|
+
import { UploadOptions } from "../multipart/options";
|
|
3
3
|
export declare function AnyFilesInterceptor(options?: UploadOptions): Type<NestInterceptor>;
|
|
@@ -14,6 +14,9 @@ function AnyFilesInterceptor(options) {
|
|
|
14
14
|
async intercept(context, next) {
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
const req = (0, request_1.getMultipartRequest)(ctx);
|
|
17
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
18
|
+
return next.handle();
|
|
19
|
+
}
|
|
17
20
|
const { body, files, remove } = await (0, any_files_1.handleMultipartAnyFiles)(req, this.options);
|
|
18
21
|
req.body = body;
|
|
19
22
|
req.storageFiles = files;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any-files-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/any-files-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,+DAA0E;AAE1E,SAAgB,mBAAmB,CACjC,OAAuB;IAEvB,MAAM,gBAAgB;QAGpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,mCAAuB,EAC3D,GAAG,EACH,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;YAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"any-files-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/any-files-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,+DAA0E;AAE1E,SAAgB,mBAAmB,CACjC,OAAuB;IAEvB,MAAM,gBAAgB;QAGpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACnE,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,mCAAuB,EAC3D,GAAG,EACH,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;YAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;AApCD,kDAoCC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NestInterceptor, Type } from
|
|
2
|
-
import { UploadOptions } from
|
|
3
|
-
import { UploadField } from
|
|
1
|
+
import { NestInterceptor, Type } from "@nestjs/common";
|
|
2
|
+
import { UploadOptions } from "../multipart/options";
|
|
3
|
+
import { UploadField } from "../multipart/handlers/file-fields";
|
|
4
4
|
export declare function FileFieldsInterceptor(uploadFields: UploadField[], options?: UploadOptions): Type<NestInterceptor>;
|
|
@@ -15,6 +15,9 @@ function FileFieldsInterceptor(uploadFields, options) {
|
|
|
15
15
|
async intercept(context, next) {
|
|
16
16
|
const ctx = context.switchToHttp();
|
|
17
17
|
const req = (0, request_1.getMultipartRequest)(ctx);
|
|
18
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
19
|
+
return next.handle();
|
|
20
|
+
}
|
|
18
21
|
const { body, files, remove } = await (0, file_fields_1.handleMultipartFileFields)(req, this.fieldsMap, this.options);
|
|
19
22
|
req.body = body;
|
|
20
23
|
req.storageFiles = files;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-fields-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/file-fields-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,mEAK2C;AAE3C,SAAgB,qBAAqB,CACnC,YAA2B,EAC3B,OAAuB;IAEvB,MAAM,gBAAgB;QAKpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;YAC/C,IAAI,CAAC,SAAS,GAAG,IAAA,+BAAiB,EAAC,YAAY,CAAC,CAAC;QACnD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,uCAAyB,EAC7D,GAAG,EACH,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;YAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-fields-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/file-fields-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,mEAK2C;AAE3C,SAAgB,qBAAqB,CACnC,YAA2B,EAC3B,OAAuB;IAEvB,MAAM,gBAAgB;QAKpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;YAC/C,IAAI,CAAC,SAAS,GAAG,IAAA,+BAAiB,EAAC,YAAY,CAAC,CAAC;QACnD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACnE,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,uCAAyB,EAC7D,GAAG,EACH,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;YAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;AAzCD,sDAyCC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NestInterceptor, Type } from
|
|
2
|
-
import { UploadOptions } from
|
|
1
|
+
import { NestInterceptor, Type } from "@nestjs/common";
|
|
2
|
+
import { UploadOptions } from "../multipart/options";
|
|
3
3
|
export declare function FileInterceptor(fieldname: string, options?: UploadOptions): Type<NestInterceptor>;
|
|
@@ -14,6 +14,9 @@ function FileInterceptor(fieldname, options) {
|
|
|
14
14
|
async intercept(context, next) {
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
const req = (0, request_1.getMultipartRequest)(ctx);
|
|
17
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
18
|
+
return next.handle();
|
|
19
|
+
}
|
|
17
20
|
const { file, body, remove } = await (0, single_file_1.handleMultipartSingleFile)(req, fieldname, this.options);
|
|
18
21
|
req.body = body;
|
|
19
22
|
req.storageFile = file;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/file-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,mEAA8E;AAE9E,SAAgB,eAAe,CAC7B,SAAiB,EACjB,OAAuB;IAEvB,MAAM,gBAAgB;QAGpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,uCAAyB,EAC5D,GAAG,EACH,SAAS,EACT,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;YAEvB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/file-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,mEAA8E;AAE9E,SAAgB,eAAe,CAC7B,SAAiB,EACjB,OAAuB;IAEvB,MAAM,gBAAgB;QAGpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACnE,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,uCAAyB,EAC5D,GAAG,EACH,SAAS,EACT,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;YAEvB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;AAtCD,0CAsCC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NestInterceptor, Type } from
|
|
2
|
-
import { UploadOptions } from
|
|
1
|
+
import { NestInterceptor, Type } from "@nestjs/common";
|
|
2
|
+
import { UploadOptions } from "../multipart/options";
|
|
3
3
|
export declare function FilesInterceptor(fieldname: string, maxCount?: number, options?: UploadOptions): Type<NestInterceptor>;
|
|
@@ -14,6 +14,9 @@ function FilesInterceptor(fieldname, maxCount = 1, options) {
|
|
|
14
14
|
async intercept(context, next) {
|
|
15
15
|
const ctx = context.switchToHttp();
|
|
16
16
|
const req = (0, request_1.getMultipartRequest)(ctx);
|
|
17
|
+
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
18
|
+
return next.handle();
|
|
19
|
+
}
|
|
17
20
|
const { body, files, remove } = await (0, multiple_files_1.handleMultipartMultipleFiles)(req, fieldname, maxCount, this.options);
|
|
18
21
|
req.body = body;
|
|
19
22
|
req.storageFiles = files;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/files-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,yEAAoF;AAEpF,SAAgB,gBAAgB,CAC9B,SAAiB,EACjB,QAAQ,GAAG,CAAC,EACZ,OAAuB;IAEvB,MAAM,gBAAgB;QAGpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,6CAA4B,EAChE,GAAG,EACH,SAAS,EACT,QAAQ,EACR,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;YAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"files-interceptor.js","sourceRoot":"","sources":["../../../../../src/multer/interceptors/files-interceptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuC;AACvC,2CAMwB;AAExB,kDAA2D;AAC3D,kDAA6E;AAC7E,yEAAoF;AAEpF,SAAgB,gBAAgB,CAC9B,SAAiB,EACjB,QAAQ,GAAG,CAAC,EACZ,OAAuB;IAEvB,MAAM,gBAAgB;QAGpB;YACE,IAAI,CAAC,OAAO,GAAG,IAAA,gCAAsB,EAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,CAAC,SAAS,CACb,OAAyB,EACzB,IAAiB;YAEjB,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,IAAA,6BAAmB,EAAC,GAAG,CAAC,CAAC;YAErC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACnE,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,6CAA4B,EAChE,GAAG,EACH,SAAS,EACT,QAAQ,EACR,IAAI,CAAC,OAAO,CACb,CAAC;YAEF,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;YAChB,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;YAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAA,UAAG,EAAC,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;KACF;IAED,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,gBAAgB,CAAC,CAAC;IAE5C,OAAO,WAAW,CAAC;AACrB,CAAC;AAxCD,4CAwCC"}
|
|
@@ -4,9 +4,6 @@ exports.getParts = exports.getMultipartRequest = void 0;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const getMultipartRequest = (ctx) => {
|
|
6
6
|
const req = ctx.getRequest();
|
|
7
|
-
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
8
|
-
throw new common_1.BadRequestException("Not a multipart request");
|
|
9
|
-
}
|
|
10
7
|
return req;
|
|
11
8
|
};
|
|
12
9
|
exports.getMultipartRequest = getMultipartRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../../src/multer/multipart/request.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAe9C,MAAM,mBAAmB,GAAG,CAAC,GAAsB,EAAE,EAAE;IAC5D,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,EAAgB,CAAC;IAE3C,
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../../src/multer/multipart/request.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAe9C,MAAM,mBAAmB,GAAG,CAAC,GAAsB,EAAE,EAAE;IAC5D,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,EAAgB,CAAC;IAE3C,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B;AAEK,MAAM,QAAQ,GAAG,KAAK,EAAE,GAAiB,EAAE,OAAsB,EAAE,EAAE;IAC1E,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjD,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,IACE,IAAI,YAAY,IAAI;YACpB,OAAO,EAAE,MAAM,EAAE,QAAQ;YACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EACnC,CAAC;YACD,MAAM,IAAI,4BAAmB,CAC3B,QAAQ,GAAG,kCAAkC,OAAO,CAAC,MAAM,CAAC,QAAQ,QAAQ,CAC7E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAhBW,QAAA,QAAQ,YAgBnB"}
|