New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-emitter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-emitter

express-emitter ===

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
888
increased by33.73%
Maintainers
1
Weekly downloads
 
Created
Source

express-emitter

Start a new HTTP server in one-line. Based on express. Emittable and controllable.

One-liner

Create a new HTTP server that is ready to accept incoming connections in one line:

import Server from 'express-emitter';

// Launches a new HTTP server

new Server();

Listen

Server extends node's EventEmitter so you can listen to it:

new Server()

  .on('listening', () => console.log('Server is listening'))

  .on('error', error => console.log(error.stack))

  .on('closed', () => console.log('Server is listening'));

Events

  • listening
  • error
  • closed
  • starting
  • closing

Stop and restart server

const server = new Server();

// Stop server
server.stop();

// Start server
server.start();

// Restart server
server.restart();

// You can chain control actions with listeners
server
  .restart()
  .on('closed', () => console.log('closed'))
  .on('listening', () => console.log('listening'));

Customize app

You can customize the express app:

new Server(app => {
  app.set('port', 4000);

  app.get('/', (req, res, next) => res.send('Welcome to my server!'));

  app.use('/', (req, res, next) => next(new Error('Only GET accepted !')));
});

Checkout express documentation for more.

FAQs

Package last updated on 16 Jan 2016

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

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