Похожие чаты

Anyone has any idea how to limit request payload? I

am getting array of objects in request payload and each element of an array is object. So how can I limit this to 10 or 50 or any value? can someone suggest how can I do this?

14 ответов

26 просмотров

Why do you want to limit it?

Adi- Автор вопроса
Thomas
Why do you want to limit it?

limit array of objects which come in request payload payload is like this": [ {'name': 'abc'}, {'name': 'adef'}..... ]

Adi
limit array of objects which come in request paylo...

create a middleware that parses the payload and check that it's an array & array.length is less than limit.

Adi- Автор вопроса
Ghazwan Aliesh
create a middleware that parses the payload and ch...

if I dont use middleware I can do something like this: app.post('/', function(req, res){ console.dir(req.body); if(req.body.length > limit){ res.sendStatus(400) } });

Adi
if I dont use middleware I can do something like t...

better do it in a middleware for re-usability. also make it typesafe.

Adi- Автор вопроса
Ghazwan Aliesh
better do it in a middleware for re-usability. als...

is status 400 correct status code (i.e bad request) in case of length greater than limit??

Adi- Автор вопроса
Thomas
yes, why?

I want to limit it to certain value because based on that array element I am making SQL query which will return 50-100 records from table so if there are more array elements in payload then the response will be huge thats why want to limit

Adi- Автор вопроса
Adi- Автор вопроса
Thomas
Why not limit the SQL queries instead?

what will be good idea?? and good practice as well?? limit SQL query records or limit request payload ??

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта