nanoexpress / legacy

[Deprecated] Nano-framework for Node.js. Use PRO version
https://nanoexpress.js.org
Apache License 2.0
107 stars 13 forks source link

How to log everything #86

Closed literakl closed 4 years ago

literakl commented 4 years ago

I fight with Chrome hiding errors: https://stackoverflow.com/questions/60917740/chrome-developer-is-hiding-status-and-response

Is there any way how to turn a raw request and response logging in Nanoexpress?

dalisoft commented 4 years ago

Hi @literakl

Thanks for issue, but this issue looks like a question, there you first asking about this and i think you should debug or wait to someone who already fixed issue. Nanoexpress provided as-is for default version, as option, if you need fast support with solution, you should become sponsor.

Thanks again for interest

literakl commented 4 years ago

Can I make a feature request - input/output logger? It is nightmare to investigate the issues when I have no idea why nanoexpress does not send any response.

dalisoft commented 4 years ago

Yes, you can create middleware for handling these, but core of project should be same as current

literakl commented 4 years ago

Do you mean something like this?

function logRequest(req, res, cb) { console.log("req = ", req); console.log("res = ", res); cb(); } app.use(logRequest);

Is it put on start or end of middlewares?

dalisoft commented 4 years ago

Yes, could be like that. Both on start and end works, but I recommend at end because of all methods and properties should be attached

literakl commented 4 years ago

app.use(logRequest) will put this middleware at start. How can I add it to the end for all requests? Thank you

dalisoft commented 4 years ago

If you want after all requests including routes itself, I think it is impossible, but before route, you can add it.

Like app.get(path, yourMiddleware, yourRoute)