UNPKG

1.52 kBJavaScriptView Raw
1import {
2 defineConfig
3} from "../chunk-IPABXONF.js";
4import {
5 BodyParserMiddleware
6} from "../chunk-XVMZ4GI3.js";
7import {
8 MultipartFile
9} from "../chunk-NRCULWNL.js";
10
11// factories/file_factory.ts
12var MultipartFileFactory = class {
13 #parameters = {};
14 /**
15 * Merge factory params
16 */
17 merge(params) {
18 this.#parameters = Object.assign(this.#parameters, params);
19 return this;
20 }
21 /**
22 * Create an instance of multipart file
23 */
24 create(validationOptions) {
25 const file = new MultipartFile(
26 {
27 fieldName: this.#parameters.fieldName || "file",
28 clientName: this.#parameters.clientName || this.#parameters.extname ? `file.${this.#parameters.extname}` : "file",
29 headers: this.#parameters.headers || {}
30 },
31 validationOptions || {}
32 );
33 file.size = this.#parameters.size || 0;
34 file.extname = this.#parameters.extname;
35 file.type = this.#parameters.type;
36 file.subtype = this.#parameters.subtype;
37 file.state = "consumed";
38 file.validate();
39 return file;
40 }
41};
42
43// factories/middleware_factory.ts
44import lodash from "@poppinss/utils/lodash";
45var BodyParserMiddlewareFactory = class {
46 #config = defineConfig({});
47 #getConfig() {
48 return this.#config;
49 }
50 merge(config) {
51 this.#config = lodash.merge(this.#config, config);
52 return this;
53 }
54 create() {
55 return new BodyParserMiddleware(this.#getConfig());
56 }
57};
58export {
59 BodyParserMiddlewareFactory,
60 MultipartFileFactory
61};
62//# sourceMappingURL=main.js.map
\No newline at end of file