Skip to content

DWTechs/Servpico-express.js

Repository files navigation

License: MIT npm version last version release date Jest:coverage

Synopsis

Servpico-express.js is an open source library to start and close Express.js service properly.

  • ⚡ Built for speed
  • 📦 Only 1 dependency to log service activity properly
  • 🪶 Very lightweight
  • 🧪 Thoroughly tested
  • 🚚 Shipped as EcmaScrypt Express module
  • 📝 Written in Typescript

Support

  • node: 22

This is the oldest targeted version.

Installation

$ npm i @dwtechs/servpico-express

Usage

import express from "express";
import { log } from "@dwtechs/winstan";
import { listen } from "@dwtechs/servpico-express";

// Usual express app initialization
const app = express();
// ...

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

// Init reference data
Promise.all([
    // Your init asynchronous functions here
  ])
  .then(() => listen(app))
  .catch((err) => log.error(`App cannot start: ${err.msg}`));

// or the simplest way if no asynchronous reference data is needed : 
// listen(app);

The library will look for an environment variable named PORT to start the service on. If not found it will default to 3000.

Test with docker

Get the container id with "docker ps" command and kill the container like this :

$ docker ps
$ docker kill --signal=SIGTERM <container_name_or_id>

API Reference

function listen(app: Express): void;
function close(server: Server): void;

Logs

Servpico-express.js uses @dwtechs/Winstan library for logging.

Contributors

Servpico-express.js is still in development and we would be glad to get all the help you can provide. To contribute please read contributor.md for detailed installation guide.

Stack

Purpose Choice Motivation
repository Github hosting for software development version control using Git
package manager npm default node.js package manager
language TypeScript static type checking along with the latest ECMAScript features
module bundler Rollup advanced module bundler for ES6 modules
unit testing Jest delightful testing with a focus on simplicity

About

Starts and closes Express.js service properly

Resources

License

Stars

Watchers

Forks

Packages

No packages published