Skip to content

Commit 910bed8

Browse files
committed
feat(@sirutils/wizard): added options for file size and body size
1 parent b284c6a commit 910bed8

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

packages/wizard/src/definitions/wizard.ts

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ declare global {
3535
port?: string
3636
host?: string
3737
logs?: boolean
38+
limit?: string
39+
limitFiles?: number
3840
}
3941

4042
interface Service<

packages/wizard/src/utils/internals/action.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ export const actionActions = createActions(
6969
ctx.params.req.headers['content-type'] !== 'application/json' &&
7070
!isInvalid
7171
) {
72-
const form = formidable(isRawObject(meta.multipart) ? meta.multipart : {})
72+
const form = formidable(
73+
deepmerge(
74+
{
75+
maxFileSize: context.options.limitFiles ?? 20 * 1024 * 1024,
76+
},
77+
isRawObject(meta.multipart) ? meta.multipart : {}
78+
)
79+
)
7380

7481
const multipart = await group(
7582
() => form.parse(ctx.params.req),

packages/wizard/src/utils/internals/service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export const serviceActions = createActions(
9595
path: `${serviceOptions.name}/${serviceOptions.version}`,
9696
aliases,
9797
mergeParams: false,
98+
bodyParsers: {
99+
json: { limit: context.options.limit ?? '100kb' },
100+
urlencoded: { extended: true, limit: context.options.limit ?? '100kb' },
101+
},
98102
})
99103

100104
if (serviceOptions.created) {

0 commit comments

Comments
 (0)