servify-express
v2.0.0
Published
A simple package to start an Express server and log port information
Readme
Servify Express
A simple Node.js package to start an Express server and log the port it's running on.
my website
Installation
From npm
To install the package from npm, run:
npm install servify-expressFrom GitHub Packages
To 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.comThen install the package:
npm install @aarondoran/servify-expressUsage
After 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.
Basic example
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.
How It Works
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.
License
This package is licensed under the MIT License.
