swaggerize-express icon indicating copy to clipboard operation
swaggerize-express copied to clipboard

Allow async handlers

Open juliusza opened this issue 7 years ago • 10 comments

Allows route handlers to be async functions

Based on https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016

Or see README for more info

juliusza avatar Jan 27 '18 15:01 juliusza

FYI, express-openapi supports this.

jsdevel avatar Jan 27 '18 22:01 jsdevel

Thanks, I will look into that lib.

juliusza avatar Jan 30 '18 12:01 juliusza

Is there a reason not to accept this PR though ? express-openapi does not work out of the box for me, I'd rather stick with swaggerize-express

juliusza avatar Mar 06 '18 13:03 juliusza

express-openapi does not work out of the box for me

@juliusza what issue were you having? Can you open one? https://github.com/kogosoftwarellc/express-openapi/issues

jsdevel avatar Mar 06 '18 17:03 jsdevel

ok, how about this one? https://github.com/kogosoftwarellc/express-openapi/issues/91

juliusza avatar Mar 08 '18 11:03 juliusza

Will review. Kraken team has been under a lot of resource constraints and it’s been hard to turn around PRs. Apologies.

tlivings avatar Mar 08 '18 14:03 tlivings

Can you add some tests?

tlivings avatar Mar 08 '18 14:03 tlivings

Also, for what it’s worth at this point https://github.com/krakenjs/hapi-openapi is more actively maintained. Unless you have some overriding preference for express applications.

tlivings avatar Mar 08 '18 14:03 tlivings

I hope test is satisfactory. Please also bump major version to 5.0.0, because this now requires native Promise support and might not work for very old nodejs versions.

Tests now require node v8 to run. But node 4.8.7 is enough for lib to work correctly.

juliusza avatar Mar 08 '18 15:03 juliusza

Also do you think you could bump enjoi version ?

https://github.com/krakenjs/swaggerize-routes/issues/94

juliusza avatar Mar 08 '18 15:03 juliusza