express-listen-one
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Express Listen One

Tiny function for listening to a single request with express.

Useful for catching a request when testing, when dealing with redirects to localhosts etc.

Install

npm install --save express-listen-one

Usage

import listen from 'express-listen-one';
 
// Maybe during testing...
 
const result = await listen ( 3333, ( req, res ) => true );
 
assert ( result === true );
 
// Maybe when dealing with redirects to localhost...
 
const tokenPromise = listen ( 3333, ( req, res ) => req.query.token );
 
request ( 'https://connect.deezer.com/oauth/auth.php?redirect_uri=http://localhost.com:3333' ); // Adding `127.0.0.1 localhost.com` to /etc/hosts is pretty useful btw
 
const token = await tokenPromise;

License

MIT © Fabio Spampinato

Readme

Keywords

Package Sidebar

Install

npm i express-listen-one

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

13.2 kB

Total Files

12

Last publish

Collaborators

  • fabiospampinato