ForgeTotal.js 5
en

Total.js 5

Limit the payload size and the timeout of a route

Total.js 5 · total5@0.0.19 routingsecuritylimits Executed against Total.js 5

At the end of a route you can add limits that start with <. <2mb, <10kb and <500b set the maximum size of the request body; <30s, <5m and <1h set the timeout of the request. A request over the limit is rejected before your handler runs.

controllers/limits.js
exports.install = function() {
	ROUTE('POST /small/ <1kb', small);
	ROUTE('POST /big/ <5mb', big);
};

function small($) {
	$.json({ ok: true });
}

function big($) {
	$.json({ ok: true });
}