Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-express

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-express - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "async-express",
"version": "0.0.2",
"version": "0.0.3",
"description": "Allow async/await syntax in Express routes and middleware",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,11 +18,11 @@ # async-express

// As a route
app.get('/', _async((req, res, next) => {
app.get('/', _async(async (req, res, next) => {
// Wait 5 seconds
await new Promise(r => setTimeout(r, 5000));
// Send a response
req.send('Waited 5 seconds successfully');
res.send('Waited 5 seconds successfully');
}));
```
The sample above can be refactored using decorator syntax as the following
The sample above can be refactored as the following

@@ -37,9 +37,8 @@ ```js

@_async
function waitForABit(req, res, next) {
const waitForABit = _async(async (req, res, next) => {
// Wait 5 seconds
await new Promise(r => setTimeout(r, 5000));
// Send a response
req.send('Waited 5 seconds successfully');
}
res.send('Waited 5 seconds successfully');
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc