1.0.0 • Published 1 month ago

@readytogo/server v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

readytogo-server

Create a pre-configured express HTTP server

Usage

import { newServer } from '@readytogo/server';

const { app, server } = newServer(3000, {});

app.get('/', (req, res) => {
  res.send('Hello World!');
});

const close = false;

if (close === true) server.close();

Note

Every call to newServer() will try to create a new server instance and listen on the given port. Subsequent calls given the same port will throw EADDRINUSE error. If you want to create multiple servers, you should use different ports. Passing an empty object {} as the config parameter to newServer() will use the default configuration. It will enable all the middleware using the default values. If you want to disable specific middleware or change the default values, you should pass the proper configuration object.