【文件属性】:
文件名称:express-dot-async:像老板一样在Express上使用Promises!
文件大小:41KB
文件格式:ZIP
更新时间:2021-05-16 04:42:15
JavaScript
表达点异步
您是否一直想像老板一样将Express与Promises一起使用?
基本
通常,您必须执行以下操作:
app . get ( '/api/songs' , ( req , res ) => {
database . find ( 'songs' )
. then ( songs => res . json ( songs ) )
. catch ( e => res . status ( 500 ) . send ( e . message ) )
} )
但是,通过express-dot-async,您可以通过以下方式做到这一点:
app . async . get ( '/api/songs' , ( ) => database . find ( 'songs' ) )
错误处理
express-dot-async包含特殊的HttpError
【文件预览】:
express-dot-async-master
----.gitignore(13B)
----README.md(1KB)
----__tests__()
--------async-route-tests.js(933B)
--------non-http-error-tests.js(2KB)
--------http-error-tests.js(2KB)
----package.json(540B)
----src()
--------index.js(2KB)
----.babelrc(33B)
----testUtils.js(264B)
----.npmignore(38B)
----yarn.lock(135KB)