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
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 |
Request Body:
{
"name": "CRISTIAN MORENO",
"email": "[email protected]",
"password": "my-secret-password"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OWFiNzkyMWQ1Yzk3NjJlZGQzZmUwZDgiLCJpYXQiOjE1MDQ0MDk4ODksImV4cCI6MTUwNDQyNzg4OX0.2gZPXZ-dQc3kQ1fcIDryHm4gIqWLvcw6guAOnP0ueGU"
}
- Git
- Node.js and npm Node >= 4.x.x, npm >= 2.x.x
- MongoDB - Keep a running daemon with
mongod
-
Run
npm install
to install server dependencies. -
Run
mongod
in a separate shell to keep an instance of the MongoDB Daemon running -
Run
npm run dev
to start the development server. It should automatically open the client in your browser when ready. -
Open browser
http://localhost:3030/api/helloworld
.
Thanks goes to these wonderful people (emoji key):
Khriztian Moreno 💻 📖 💡 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!