Sample list of API endpoints and their functionalities:
- /books (POST) - Insert details a new book .
- /books (GET) - Get a details of all books.
- /books/:id (GET) - Get details of a specific book by ID.
- /api/courses (POST) - Create a new course.
- /books/:id (PUT) - Update an existing details of a book by ID.
- /books/:id (DELETE) - Delete a book by ID.
Sample API requests and responses:
- GET /books: Get details of all books Response: Details of all books in the database
- GET /books/:id: Get details of a book by ID Response: Details of book with the specified ID
- POST /books: Insert a new book Request: Book details in the request body Response: Details of newly created Book
- PUT /books/:id: Update details of existing book by ID Request: The updated book details in the request body Response: The updated book details
- DELETE /api/courses/:id: Delete a book by ID Response: A success message indicating that the book has been deleted.
// Instructions to set up and run the application locally
- Download the project.
- Open it in an IDE.
- Open terminal and run "npm install". This will install all required packages.
- Create an .env file containing two constants i.e; PORT and MONGODB_URL.
- Set PORT = 3000 or any other Port in which you want to run the app.
- Set MONGODB_URL = connection string provided by mongoDb Atlas, make sure to replace by password.
- Now run the server using "npm start".
- You can use Postman to test APIs.