npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

expressjs-microservice

v0.0.13

Published

An opinionated minimalist boilerplate for expressjs based microservices.

Downloads

40

Readme

Why expressjs-microservice boilerplate?

Easy to use opinionated ExpressJS based micro-service boilerplate. This boilerplate provides a solid pattern that developers can use to scaffold and start devleop a ExpressJS (NodeJS) based microservice within seconds. The boilerplate demonstrates several key design patterns that include:

  • Creating complex routes with route nesting
  • Use of most popular tools that are must have for any NodeJS based API project.
  • Use of Sinon for stubbing, mocking and spying on unit tests.
  • Use of supertest to unit and integration test HTTP endpoints and API endpoints.
  • Testing promises with Jasmine, Sinon, Supertest and Chai.
  • Separation of concerns through use of service classes for business logic, data access classes for database operations and pure routes for API endpoints.
  • Exception handling and exception propagation

What does it provide

This boilerplate provides pre-configured:

  1. ExpressJS REST API template
  2. Swagger documentation and Swagger UI
  3. Jasmine, Sinon, Chai, Supertest configuration for Unit and integration tests.
  4. Pre-configured jasmine spec reporter
  5. Jasmine Node Debug for debugging unit tests.
  6. Fully configured istanbul test coverage
  7. Winston logger for logging to file and console with daily rotating log file module.

How to install?

Getting started with this boilerplate is easy. There are two ways to install and use it

Installing manually

Clone this repo on your workstation

git clone https://github.com/doomsbuster/expressjs-microservice.git YOUR_PROJ_NAME

Installing as node module

Boilerplate is also available as module from NPM and Yarn registry.

npm install expressjs-microservice

Once you have installed the module, copy the expressjs-microservice to your project directory.

cp -R ./node_modules/expressjs-microservice/* .    

Getting started

Once you have installed the boilerplate, running it is easy:

Run

npm install

Start the application using

npm start

Point your browser at http://localhost:3000, you should see the swagger documentation for the boilerplate API.

The base API is available at the route /api e.g. http://localhost:3000/api/posts.

Running unit tests

You can trigger unit tests that have full coverage using istanbul and spec reporting using jasmine-spec-reporter using the following command

npm test

Running integration tests

All intgration tests whose names end in -IT.js for example it/posts-IT.js created under the expressjs-microservice/it directory will be executed as a part of the integration test command described below.

The name of the file must match the globbing pattern **/*-IT.js.

  • posts-IT.js - Matched
  • posts-it.js - Not matched

You can customize this behavior by updating the spec/support/jasmine-integ.json file.

Run your integration test using the command:

npm run integtest

What does it not provide?

This project does come with test coverage for all files as they are expected to be removed or different for your projects. Samples are for demonstration of the concept and the pattern only.

Contributing

Fork the repo and submit a pull request.

License

Mr. Doomsbuster doesn't care about attribution. All source code is license under Do What The Fuck You Want To (WTFPL) public license.