Skip to content

Akashay-Anand/Rest-API-Project

Repository files navigation

Rest-API-Project

OverView

In this project I will be building A full fledged API backend using nodejs, express, and mongodb

the entire process will be devided into multiple stages of development. The commits will also be ordered by them.

Features

  • Follows MVC Structure
  • Uses MongoDB Atlas, NodeJS
  • CRUD implementation
  • Global error handling
  • Filtering through query parameters
  • Sorting through query parameters
  • limiting fields through query parameters
  • Text Indexe on title and description
  • implemented pagination

Deployment and Documentation

Use the live link to send the api request to the server

check out the documentation to know more about the Endpoints in this api note - documentation is of production env. so whatever api request link is there, should work fine




Development Phase

Phase - 01 📈

  • Stage 1:

  • Inital setup & initialization project with npm and modules

  • create a basic api server with one or two end points without using express

  • create a same server using express

  • Perform CRUD operations on express

  • Completed

  • Stage 2:

  • decide API context and use case (decision Job related api)

  • Create project folders

  • follow MVC design pattern

  • Create MongoDB database

  • integrate '.env' file and mongodb configuration and conect to database

  • create database schema and models

      • implemented and tested job schema on mongo atlas db(online);
  • perform CRUD operations on database

  • Build multiple endpoints

  • Stage 3:

  • restructure code base

  • create documentation

  • host on live server.

  • Wrapup phase-1 development. next phase will start latter

  • restructure code base and Readme

Phase 02 📈

  • Stage 2.1

  • Working on Aggregation concept
  • Error handling -- [x] error handling classes
  • Advance filterning Features -- Now can search job through query parameters
    -- Can sort dson responses using query parameters -- Can filter to show only needed parameters -- pagination



Running the Projec

  • steps to follow

Clone the repository

git clone https://github.com/Akashay-Anand/Rest-API-Project.git

move into the repository

cd "Rest-API-Project"

[Note] Do setup environment variables as per your local configuration/database

// .env example file

PORT = 8080
dbDriver = http://localhost:8080 // if using Atlas online replace it here
add other variables if needed

Install dependencies

npm install

start server // like in this project server.js is our executable file

nomemon server.js

Now your server may start working properly. So we you can test it through its endpoint

either you can use online platform or tools like postman for this

for endpoints checkout the documentation.

Dependencies

  "dependencies": {
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "mongoose": "^7.5.2",
    "nodemon": "^3.0.1",
    "slugify": "^1.6.6",
    "validator": "^13.11.0"
  }



Folder structure

files which are not part of this Project

  • simple_http_api.js , simple_express_api.js , database.js , basics.md ...

[ note ] apart from the above file, rest of the files and folder may contain code related to this project.

Folders details

  • config > contains configuration file. i.e: environment variables , .env , etc

  • routes > routes will contains all route path

  • models > this will contain database model and schema

  • controllers > holds resopnse for routes

  • Utils > contains supportive methods/features

Documentation for Help




Remarks By Anand

  • well never know building api without using any framework is that much lengthy, well after working on 'simple_http_api.js' I realize that... Kudos to people who build these modules/framework 🧑🏻‍💻✌🏻🤖

  • Now I have writen Simple API in both http (simple_http_api.js) and ExpressJS (simple_express_api.js) ;

  • after analyzing both files we can say that ExpressJS simplifies code complexity and improve readability.

// issue to resolve // anyone can add data init big issues

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published