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
- node: 22
This is the oldest targeted version.
$ npm i @dwtechs/servpico-express
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.
Get the container id with "docker ps" command and kill the container like this :
$ docker ps
$ docker kill --signal=SIGTERM <container_name_or_id>
function listen(app: Express): void;
function close(server: Server): void;
Servpico-express.js uses @dwtechs/Winstan library for logging.
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.
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 |