Skip to content

ricardocanelas/node-express-mongodb-restful-example

Repository files navigation

😃 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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published