A simple Node.js package to start an Express server and log the port it's running on.
To install the package from npm, run:
npm install servify-expressTo install the package from GitHub Packages, first configure npm to use the GitHub Package Registry for the @aarondoran scope by adding a .npmrc file in your project:
@aarondoran:registry=https://npm.pkg.github.com
Then install the package:
npm install @aarondoran/servify-expressAfter installing the package, you can start an Express server with a single function call. You can also optionally enable rate limiting if you want.
- Import the package into your project.
const StartServer = require('servify-express');
// OR if installed from GitHub Packages:
const StartServer = require('@aarondoran/servify-express');- Call the
listenmethod and pass in the port number. You may also pass an options object if you want to enable rate limiting.
const StartServer = require('servify-express');
StartServer.listen(3000);
With optional rate limiting:
const StartServer = require('servify-express');
StartServer.listen(3000, {
rateLimit: {
windowMs: 60000,
max: 50
}
});
if you dont add a port it will default to 3000.
listen() starts an Express server and logs:
Server is running on port <PORT_NUMBER>
Rate limiting is only applied if you include the rateLimit option. If you leave it out, no rate limiting will be used.
This package is licensed under the MIT License.