-
Is there a way to increase the max body size? We used to do the following: const app = express();
app.use(bodyParser.json({ limit: "10mb" }));
app.use(express.json({ limit: "10mb" }));
app.use(express.urlencoded({ limit: "10mb", extended: true })); We have it ported over to this library like this: export const customEndpointFactory = new EndpointsFactory({
resultHandler: customResultHandler,
config: serverConfig,
})
.addExpressMiddleware(bodyParser.json({ limit: '10mb' }))
.addExpressMiddleware(express.json({ limit: '10mb' }))
.addExpressMiddleware(express.urlencoded({ limit: '10mb', extended: true })) But I don't think this is actually working (if the payload is too big I'm getting a 400 error). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @JUNIORCO , first of all I have to mention that you can supply the JSON parser via config option createConfig({
server: {
jsonParser: express.json({ limit: "10mb" }),
// ...
}
})
However, since you're also using other parsers ( Thus, you can keep your original Check out this chapter for more details: https://github.com/RobinTail/express-zod-api#connect-to-your-own-express-app |
Beta Was this translation helpful? Give feedback.
Hello @JUNIORCO ,
first of all I have to mention that you can supply the JSON parser via config option
jsonParser
.addExpressMiddleware
might not suit here since it's being executed after parsing the body.However, since you're also using other parsers (
.urlencoded
), I'd recommend going with.attachRouting()
approach instead ofcreateServer()
.Thus, you can keep your original
app
initialization with all those limit adjustments.Check out this chapter for more details: https://github.com/RobinTail/express-zod-api#connect-to-your-own-express-app