Rest API for Acronyms.
- Clone or download using link: https://github.com/r97draco/backend-api
git clone https://github.com/r97draco/backend-api
- Run following command to install node modules in the root directory of Project.
npm install
- Run following in terminal to start the server on localhost:3000
node server.js
- Run following in terminal to start the server on localhost:3000 using nodemon
npm run dev
It will take 3 Parameters limit, page and search. By deafault it will return limit= 10, page=1 and first 10 Results that are in database.
-
POST http://localhost:3000/acronym
send raw data in body using json format. we can send id but if no id is given it will automatically generate a random one.
Eg: POST call http://localhost:3000/acronym.
attach raw json { "acronym" ="OMW", "definition": "On my Way" } to the body of the request.
This request will create acronym with a random unique ID and add it to the Database -
PATCH http://localhost:3000/acronym/
Eg. PATCH call http://localhost:3000/acronym/123 Add id of acronym to be patched at end which 123
attach json { "acronym" ="lmk", "definition": "Let me Know" } to the body of the request.
This request will update acronym with _id=123 with the given data. -
DELETE http://localhost:3000/acronym/
add _id of the acronym to be deleted at the end for eg:-
http://localhost:3000/acronym/123 will delete acronym with id-123 if its present
Import it as a file the Postman App.
postman-file/FulhausBE.postman_collection.json
- server.js is the root file which will start the server.
- data.json is where our data is store, change the file content to update the data.
- routes/acronyms.js is the file containing API routes for /acronym
- controllers/method.js contains all the function and methods for Database query and manipulation.
- express@4.18.2
- nodemon@2.0.21