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.
- 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
Use the live link to send the api request to the server
- if you are testing it on local environment then this would be the root address for api requests
- Live Link: https://rest-api-project-production.up.railway.app
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
-
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
-
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
-
restructure code base
-
create documentation
-
host on live server.
-
Wrapup phase-1 development. next phase will start latter
-
restructure code base and Readme
- 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
- steps to follow
Clone the repository
git clone https://github.com/Akashay-Anand/Rest-API-Project.gitmove 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 neededInstall dependencies
npm installstart server // like in this project server.js is our executable file
nomemon server.jsNow 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": {
"dotenv": "^16.3.1",
"express": "^4.18.2",
"mongoose": "^7.5.2",
"nodemon": "^3.0.1",
"slugify": "^1.6.6",
"validator": "^13.11.0"
}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
- https://expressjs.com/en/starter/basic-routing.html
- https://expressjs.com/en/guide/routing.html
- https://expressjs.com/en/guide/using-middleware.html
- https://www.geeksforgeeks.org/express-js/
-
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