Home

Awesome

Node.JS - Scaffolding API

All Contributors PRs Welcome

Hello, and welcome! This Node.JS sample application that demonstrates an architecture for building a complete production API with Node.JS, Express.JS and MongoDB It features an architectural demonstration of these features:

Express Router and Routes

RouteHTTP VerbRoute MiddlewareDescription
/api/usersGETGet list of users
/api/usersPOSTCreates a new user
/api/users/:idGETisAuthenticatedGet a single user
/api/users/:idDELETEhasRole('admin')Deletes a user, restriction: 'admin'
/api/users/meGETisAuthenticatedGet my info
/api/users:id/passwordPUTisAuthenticatedChange a users password

Usage

Basic example Create USER /api/users:

Request Body:

{
  "name": "CRISTIAN MORENO",
  "email": "khriztianmoreno@myemail.com",
  "password": "my-secret-password"
}

Response:

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OWFiNzkyMWQ1Yzk3NjJlZGQzZmUwZDgiLCJpYXQiOjE1MDQ0MDk4ODksImV4cCI6MTUwNDQyNzg4OX0.2gZPXZ-dQc3kQ1fcIDryHm4gIqWLvcw6guAOnP0ueGU"
}

Getting Started

Prerequisites

Developing

  1. Run npm install to install server dependencies.

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

  3. Run npm run dev to start the development server. It should automatically open the client in your browser when ready.

  4. Open browser http://localhost:3030/api/helloworld.

Contributors

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<img src="https://avatars1.githubusercontent.com/u/1481964?v=4" width="100px;"/><br /><sub>Khriztian Moreno</sub><br />💻 📖 💡
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!