-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any plans to support promises? #1588
Comments
Hey @StarpTech, Thank you for taking the time to open this issue. Promises have some outstanding issues making them unsuitable for server side rest frameworks. While they are certainly the future, and will more than likely have some sort of support in this library in the future, there are currently no plans or timelines for treating them as first class constructs. The most thorough conversation around including promises can be found here: #1304 There are several other cases where proposals have been made for including promises and we have concluded they aren't mature enough yet for our use case. |
Hi @retrohacker thank you, that's reasonable. |
Cls suffers with native promise btw. It's a horrid thing to discover in the
middle of a project.
Em 6 de fev de 2018 7:26 AM, "Dustin Deus" <[email protected]>
escreveu:
… Hi @retrohacker <https://github.com/retrohacker> thank you, that's
reasonable.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1588 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAbHuFXD7Rg9PHXgwj8yWV3TNb0JZCRRks5tSBqngaJpZM4RQFv6>
.
|
We wanted to use promises in our middleware and our route handlers, so we wrote two wrappers than can convert a promise-returning handler into a restify-compatible handler. Example: server.get(
{ path: '/users/_self', version: VERSION },
middleware(authUserMiddleware),
controller(getUserSelf)
);
async function authUserMiddleware(req) {
const user = await authHelper.findUserFromToken(req.headers['x-auth-token']);
if (!user) throw Error("No user found!");
});
function getUserSelf() {
return Promise.resolve({
name: 'Example User',
color: 'green'
});
} You can get the two wrappers here: https://gist.github.com/joeytwiddle/a3a038d88b9a689bddbfe7eab1b459af |
Restify Version
Any
Feature Request
Use Case
Node.Js is increasingly developing but promises and async / await are the new standard to deal with asynchrony without a performance loss.
Are you willing and able to fix this?
Yes
In order to be compatible with the latest standard and be an example for "The future of Node.js REST development"
The text was updated successfully, but these errors were encountered: