Skip to content

pablos4nt0s/node-express-api-example

Repository files navigation

node-express-api-example travis Coverage Status Issue Count Commitizen friendly

simple, robust, REST API implementation

Node.js implementation of a REST API using express and MongoDB. Also helps your team to promote best practices by following simple conventions.

This example retrieves a list of addresses by a city or postal code.

Features

  • Code Linting ESLint. eslint-config-airbnb.
  • Auto server restart nodemon.
  • Code Coverage via nyc.
  • Secure app via helmet.
  • Uses yarn over npm.
  • Has .editorconfig which helps developers define and maintain consistent coding styles between different editors and IDEs.

Install dependencies

Clone the repo:

git clone https://github.com/rectius/node-express-api-example.git
cd node-express-api-example

Install yarn:

npm install -g yarn node-env-run

Install dependencies:

yarn

Configure

Environment variables:

# rename
cp .env.example .env

Database:

# Import data to local mongodb using mongoimport
mongoimport -h localhost -d aula-ufscar -c postalcode --drop  --file ./bd.json --jsonArray

Running

Run server:

# Start server
yarn start

Then access the example in the browser in http://localhost:3000

Examples

# Check healthcheck
curl -i http://localhost:3000/healthcheck

# Get addresses by postal code
curl -i http://localhost:3000/api/address/postalcode/18046390

# Get addresses by city
curl -i http://localhost:3000/api/address/city/Sorocaba

Tests

Tests:

# Run tests with code coverage
yarn test

Maintainers

About

API Implementation using Node and Express

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages