I
I
IDONTSUDO2019-11-04 13:42:05
Node.js
IDONTSUDO, 2019-11-04 13:42:05

Is it possible to issue an answer in Express. And continue the thread?

router.post('/signin', signin,securityWrite,securityFind,NewWarningNews)

I'm making a security system like VK. And a bunch of handlers are hung on the authorization endpoint. Who go to the database and look for records there. All this lasts plus or minus a long 60ms-120ms. Can I somehow issue an answer, but continue the stream?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IDONTSUDO, 2019-11-04
@IDONTSUDO

res.status(200);
return next();
everything was decided

A
Arthur Mustafin, 2019-11-04
@virtual_hack2root

It is necessary to refuse authorization based on the session cookie, and switch to authorization based on the JWT token, it has a payload, and scopes, that is, applicability zones, including custom properties, the lifetime of the token, so that it can be authorized on the client without contacting The database, that is, the authorization server does not need to access the database, since all information comes in payload, and only the validity of the token is checked (its lifetime, and applicability to this resource), that is, you need to switch to OAuth2 authorization (based on JWT -token), or JWT authorization, implement one of the schemes, and do not use a database call wherever the user is validated, limited only to the validation of the authorization server (1-2 ms), and the server that returns the initial token with payload for the user. Same way,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question