Skip to content

A node.js sample application that demonstrates an architecture for building a complete production API with Node.JS, Express.JS and MongoDB

License

Notifications You must be signed in to change notification settings

khriztianmoreno/nodejs-scaffolding

Repository files navigation

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:

  • Built with Node.js and Express
  • REST API with authentication scheme

Express Router and Routes

Route HTTP Verb Route Middleware Description
/api/users GET Get list of users
/api/users POST Creates a new user
/api/users/:id GET isAuthenticated Get a single user
/api/users/:id DELETE hasRole('admin') Deletes a user, restriction: 'admin'
/api/users/me GET isAuthenticated Get my info
/api/users:id/password PUT isAuthenticated Change a users password

Usage

Basic example Create USER /api/users:

Request Body:

{
  "name": "CRISTIAN MORENO",
  "email": "[email protected]",
  "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):


Khriztian Moreno

💻 📖 💡

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

About

A node.js sample application that demonstrates an architecture for building a complete production API with Node.JS, Express.JS and MongoDB

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published