1 | import {
|
2 | defineConfig
|
3 | } from "../chunk-IPABXONF.js";
|
4 | import {
|
5 | BodyParserMiddleware
|
6 | } from "../chunk-XVMZ4GI3.js";
|
7 | import {
|
8 | MultipartFile
|
9 | } from "../chunk-NRCULWNL.js";
|
10 |
|
11 |
|
12 | var MultipartFileFactory = class {
|
13 | #parameters = {};
|
14 | |
15 |
|
16 |
|
17 | merge(params) {
|
18 | this.#parameters = Object.assign(this.#parameters, params);
|
19 | return this;
|
20 | }
|
21 | |
22 |
|
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 |
|
44 | import lodash from "@poppinss/utils/lodash";
|
45 | var 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 | };
|
58 | export {
|
59 | BodyParserMiddlewareFactory,
|
60 | MultipartFileFactory
|
61 | };
|
62 |
|
\ | No newline at end of file |