ricardocanelas / node-express-mongodb-restful-example

Simple RESTful API implementation on Node.js + Express + MongoDB.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ˜ƒ Node.js - Express - MongoDB - RESTful

Simple RESTful API implementation on Node.js + Express + MongoDB.

Depedencies:

  • βœ”οΈ Express 4.16
  • βœ”οΈ Mongoose 5.3
  • βœ”οΈ Passport 0.4
  • βœ”οΈ Babel 7.1
  • βœ”οΈ Mocha 5.2
  • βœ”οΈ Chai 4.2
  • βœ”οΈ Nyc 13.1
  • βœ”οΈ Husky 1.1.3
  • βœ”οΈ Eslint 5.8
  • βœ”οΈ Prettier 1.14

πŸ‘‰πŸ» Prerequisites

MongoDB

Do not forget to add location of MongoDB's bin folder to PATH env variable.

mongod --version

NodeJs

node --version

Yarn

npm install -g yarn

πŸ‘‰πŸ» Getting Started

Run mongod in a separate shell to keep an instance of the MongoDB Daemon running

mongod

Clone the repo and use yarn to install dependecies

git clone https://github.com/ricardocanelas/node-express-mongodb-restful-example
cd node-express-mongodb-restful-example
yarn install

Start server

yarn start

Then visit http://localhost:3001/api/posts for example.

Test

# Run tests
yarn test

# Run test along with code coverage
yarn test:coverage

Lint

# Lint code with ESLint
yarn lint

# Run lint on any file change
yarn lint:fix

Deployment

yarn build
yarn serve

Seed

yarn seed

πŸ‘‰πŸ» API Endpoint

POSTS

  • GET api/posts - Get all of the posts
  • GET api/posts/count - Get the quantity of the posts
  • GET api/posts/:id - Get the details of a single post
  • POST api/posts/ - Add a new post.
  • PUT api/posts/:id - Edit the details of an existing post
  • DELETE api/posts/:id - Delete a single post

USERS

  • POST api/signin - Sign In
  • POST api/signup - Sign Up
  • GET api/users - Get All of the users (required auth)
  • GET api/users/count - Get the quantity of the users
  • GET api/users/:id - Get the details of an user
  • PUT api/users/:id - Edit the details of an existing user
  • DELETE api/users/:id - Delete an user

πŸ‘ My Inspirations

Demos

Documentations

Tests

Validations

Authentication

About

Simple RESTful API implementation on Node.js + Express + MongoDB.

License:MIT License


Languages

Language:JavaScript 100.0%