Hello and welcome! This Node.JS project demonstrates a simple architecture building a full API with Node.JS, Express.JS, and MongoDB presents an architectural demo of these features:
- Built with Node.js and Express
- Mongoose ODM
- REST API
Route | HTTP Verb | Route Middleware | Description |
---|---|---|---|
/api/helloworld | GET | Show a simple message | |
/api/notes | GET | Get list of notes | |
/api/notes | POST | isAuthenticated() |
Creates a new notes |
/api/notes/:id | GET | Get a single notes | |
/api/notes/:id | DELETE | hasRole(['company', 'viewer']) |
Deletes a task |
The use of endpoints is very simple, previously you could see a table of endpoints that you can call, if you need to create a note or log in, here we have some examples.
Request Body:
{
"email": "[email protected]",
"password": "12345"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MGFjNjM1MTljZjlkNTQ5YjA3YWU2NTEiLCJpYXQiOjE2MjE5MTMyNjIsImV4cCI6MTYyMTk5OTY2Mn0.WkptwtzkfxNu5sQ28idbt4bJ7RDbXvVNlZXF0Z0ht-0"
}
Request Body:
{
"firstName": "john",
"lastName": "doe",
"password": "123456",
"email": "[email protected]"
}
Response:
{
"fullname": "JOHN doe",
"role": "viewer",
"email": "[email protected]"
}
Request Body:
{
"content": "Create project nodejs",
"date": "2021-05-30T17:30:31.098Z",
"important": true
}
Response:
{
"content": "Create project nodejs",
"important": true,
"date": "2021-05-30T17:30:31.098Z",
"_id": "61b370d4d36823961380d96f",
"createdAt": "2021-12-10T15:23:00.603Z",
"updatedAt": "2021-12-10T15:23:00.603Z",
"__v": 0
}
- Git
- Node.js and npm Node >= 14.15.x, npm >= 6.14.x
- MongoDB - Keep a running daemon with
mongod
-
Run
npm install
to install server dependencies. -
Configure the env
$ cp .env.example .env
-
Update
.env
with the required info -
Run
npm run dev
to start the development server.