2
GitHub - studboo/boo-boo-api
source link: https://github.com/studboo/boo-boo-api
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
About this Application:
- This is a MongoDB auto CURD API generator
- All you need to do is to provide some information about your database and the application will generate the API for you
- Each API will have the following methods:
- File
router.js
will have the following methods:- GET: Get all the data
- GET: Get a single data
- POST: Create a new data
- PUT: Update a data
- DELETE: Delete a data
- File
How to use this application:
- Clone the project
- We are using PNPM here so you can install it using
npm install -g pnpm
- Run
pnpm install
to install all the dependencies - Update
sample.env
file and rename it to.env
MONGO_DB_URL
is the URL of your MongoDB databaseMONGO_DB_USER
is the username of your MongoDB databaseMONGO_DB_PASSWORD
is the password of your MongoDB database
How to add data to your database:
DB
Folder containstest.ts
file- You can add your data to the database using this file and delete
test.ts
after you are done
Routes that will be generated from filename test.ts
:
GET /api/v1/test
will get all the data from the databaseGET /api/v1/test/:id
will get a single data from the databasePOST /api/v1/test
will create a new data in the databasePUT /api/v1/test/:id
will update a data in the databaseDELETE /api/v1/test/:id
will delete a data from the database
How to Run the application:
- Run
pnpm start
to start the application usingnodemon
- Run
pnpm build
to build the application and run it usingnode
- Run
pnpm test
to run the tests
Use Postman for Testing
- Import
Auto CRUD sample.postman_collection.json
file to your postman frompostman
folder
Enjoy!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK