Skip to content

Aarondoran/servify-express

Repository files navigation

Servify Express

NPM Last UpdateGitHub last commitGitHub Repo starsGitHub watchersGitHub forksGitHub License

A simple Node.js package to start an Express server and log the port it's running on.

Installation

From npm

To install the package from npm, run:

npm install servify-express

From 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.com 

Then install the package:

npm install @aarondoran/servify-express

Usage

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.

  1. Import the package into your project.
constStartServer=require('servify-express');// OR if installed from GitHub Packages:constStartServer=require('@aarondoran/servify-express');
  1. Call the listen method 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.

About

express package form easily starting the server

Resources

License

Security policy

Stars

Watchers

Forks

Packages