edvansts / node-crud-api

🦍 A CRUD( Create, Read, Update and Delete) application built with js NodeJs and ExpressJs using the NoSQL database MongoDB 🦍

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-crud-api

🦍 A CRUD( Create, Read, Update and Delete) application built with js NodeJs and ExpressJs using the NoSQL database MongoDB 🦍

How run? πŸ‘¨β€πŸ’»

Requirements:

  1. Visual Studio Code or other JavaScript IDE
  2. NodeJS
  3. MongoDB

You need to have these technologies installed before attempting to run the project

First, install the dependencies using the terminal by typing npm install

Now just run npm run dev, and that's it, the application will already be running on your machine in http://localhost:3000.

To test the routes, I recommend Insomnia, currently my favorite API Client tool, another option to use is Postman, if you prefer.

Below, the API routes implemented to date will be listedπŸ‘‡

Routes 🌲

  • /auth

    • POST /register : Here you can register users;

      //Request body example
        {
           "email": "example@gmail.com",
           "password": "123456789",
           "name":"Edvan Matos"
         }
    • POST /authenticate : Here you can authenticate a user, generating a token for him;

      //Request body example
        {
           "email": "example@gmail.com",
           "password": "123456789",
           "name":"Edvan Matos"
         }
    • POST /forgot-password : Here you can generate a token for reset password;

      //Request body example
        {
           "email": "example@gmail.com",
         }
    • POST /reset-password : Here you can reset a user password;

      //Request body example
        {
           "email": "example@gmail.com",
           "newPassword": "12345",
       "token": "c79e37f13212aef7485830ecd13fc03cb6ef36de"
        }
  • /projects All requests in project router have authentication, send a authorization token through cookies header

    • GET / : Here you can get an array of your user projects;
      //Response example
      {
      "projects": [
          {
            "tasks": [
      	"605ca1f169eef12f3d782ce3",
      	"605ca1f169eef12f3d782ce4"
            ],
            "_id": "605ca0146cdc4f2d5b428118",
            "title": "Project1",
            "description": "Now you'll be a rockstar",
            "createdAt": "2021-03-25T14:37:08.597Z",
            "user": {
      	"_id": "605c915ea9d68f2041366054",
      	"email": "example@gmail.com",
      	"name": "Edvan Matos",
      	"createdAt": "2021-03-25T13:34:22.015Z",
            },
          },
          {
            "tasks": [
      	"605ca1f169eef12f3d782ce3",
      	"605ca1f169eef12f3d782ce4"
            ],
            "_id": "605ca0146cdc4f2d5b428118",
            "title": "Project2",
            "description": "In this project you'll make a history",
            "createdAt": "2021-03-25T14:37:08.597Z",
            "user": {
      	"_id": "605c915ea9d68f2041366054",
      	"email": "example@gmail.com",
      	"name": "Edvan Matos",
      	"createdAt": "2021-03-25T13:34:22.015Z",
            },
          }
       ]
       }
    • GET /:projectId : Here you can get an especific project of your user;
      //Response example
      {
        "project": {
          "tasks": [
            {
      	"_id": "605ca1f169eef12f3d782ce3",
      	"title": "Second task",
      	"description": "Go exercise in https://mova-se.ga πŸ€“"
      	"project": "605ca0146cdc4f2d5b428118",
      	"user": "605c915ea9d68f2041366054",
      	"createdAt": "2021-03-25T14:45:05.007Z",
            },
            {
      	"_id": "605ca1f169eef12f3d782ce4",
      	"title": "MakeFirst",
      	"description": "I need to be a normal people",
      	"project": "605ca0146cdc4f2d5b428118",
      	"user": "605c915ea9d68f2041366054",
      	"createdAt": "2021-03-25T14:45:05.011Z",
            }
          ],
          "_id": "605ca0146cdc4f2d5b428118",
          "title": "Project2",
          "description": "In this project you'll make a history",
          "createdAt": "2021-03-25T14:37:08.597Z",
          "user": {
            "_id": "605c915ea9d68f2041366054",
            "email": "edvan.stt02@gmail.com",
            "name": "Edvan Matos",
            "createdAt": "2021-03-25T13:34:22.015Z",
          },
        }
      }
    • POST / : Here you can create a project;
      //Request body example
      {
      "title": "Project2",
      "description": "Making history",
      "tasks": [
      	{
      		"title": "MakeFirst",
      		"description": "I need to be a normal people"
      	},
      	{
      		"title": "Second task",
      		"description": "Go exercise in https://mova-se.ga πŸ€“"
      	}
      ]
      }
    • PUT /:projectId : Here you can update a project;
      //Request body example
      {
      "title": "Project2NewName",
      "description": "Making history and updating him",
      "tasks": [
      	{
      		"title": "Tenth task",
      		"description": "I need to update and make more historys"
      	},
      ]
      }
    • DELETE /:projectId : Here you can delete a project, it will return the deleted project);
      //Response example
      {
        "project": {
          "tasks": [
          	"605ca1f169eef12f3d782ce3", 
      	"605ca0146cdc4f2d5b428118",
          ],  
          "_id": "605ca0146cdc4f2d5b428118",
          "title": "Project2",
          "description": "In this project you'll make a history",
          "createdAt": "2021-03-25T14:37:08.597Z",
          "user": {
            "_id": "605c915ea9d68f2041366054",
            "email": "edvan.stt02@gmail.com",
            "name": "Edvan Matos",
            "createdAt": "2021-03-25T13:34:22.015Z",
          },
        }
      }

About

🦍 A CRUD( Create, Read, Update and Delete) application built with js NodeJs and ExpressJs using the NoSQL database MongoDB 🦍


Languages

Language:JavaScript 99.2%Language:HTML 0.8%