Skip to content

Commit

Permalink
Pass options to form contructor (#2640)
Browse files Browse the repository at this point in the history
* Pass options to form contructor

* Only apply form options when set

---------

Co-authored-by: Hendrik Haas <hh@hpm.agency>
  • Loading branch information
321hendrik and Hendrik Haas committed Dec 2, 2023
1 parent d164975 commit a3ff426
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/config/web.ts
@@ -1,6 +1,8 @@
import * as os from "os";
import { ActionheroConfigInterface } from "..";

import type { Options as FormParserOptions } from "formidable";

const namespace = "web";

declare module ".." {
Expand Down Expand Up @@ -83,7 +85,7 @@ export const DEFAULT = {
keepExtensions: false,
maxFieldsSize: 1024 * 1024 * 20,
maxFileSize: 1024 * 1024 * 200,
},
} as FormParserOptions,
// Should we pad JSON responses with whitespace to make them more human-readable?
// set to null to disable
padding: 2,
Expand Down
7 changes: 5 additions & 2 deletions src/servers/web.ts
Expand Up @@ -694,8 +694,11 @@ export class WebServer extends Server {
connection.rawConnection.req.headers["Content-Type"])
) {
connection.rawConnection.form = new formidable.IncomingForm();
for (i in this.config.formOptions) {
connection.rawConnection.form.options[i] = this.config.formOptions[i];
if (this.config?.formOptions) {
for (i in this.config.formOptions) {
connection.rawConnection.form.options[i] =
this.config.formOptions[i];
}
}

let rawBody = Promise.resolve(Buffer.alloc(0));
Expand Down

0 comments on commit a3ff426

Please sign in to comment.