New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

express-extensions

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-extensions

Small extensions to [Express](https://expressjs.com/)

latest
npmnpm
Version
1.0.1
Version published
Weekly downloads
9
80%
Maintainers
1
Weekly downloads
 
Created
Source

Express Extensions

Small extensions to Express

Async Router

Define async routes:

const express = require('express')
const { asyncRouter, respond } = require('express-extensions')
const getAccountInfo = require('./getAccountInfo')

const app = express()
const router = asyncRouter()

router.$get('/accounts/:accountId', async (req, res) => {
  const { accountId } = req.params
  const accountInfo = await getAccountInfo(accountId)
  respond(accountInfo, res) // responds with 404 if accountInfo is falsey.
})

app.use(router)

Start/Stop server

If your HTTP server has open connections (such as WebSocket or EventSource), server.close will hang. This isn't good for tests. The WebServer class will destroy those connections first, preventing this.

WebServer also provides a Promise API for starting and stopping the server, and also lets you choose a random port:

const express = require('express')
const { WebServer } = require('express-extensions')
const app = express()

const webServer = new WebServer(app)
const port = await webServer.listen(9988) // use 0 to select a random port

await webServer.stop() // This will kill keep-allive connections too

FAQs

Package last updated on 23 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts