This project is a simple Book Store API built using Node.js with Express for the backend and Vanilla JavaScript for the frontend. It allows users to view and add books to the store via a RESTful API.
- GET
/api/books
: Fetch all books. - POST
/api/books
: Add a new book to the store.
Make sure you have the following installed:
- Node.js
- npm (comes with Node.js)
- Clone the repository:
git clone https://github.com/yourusername/bookstoreapi.git cd bookstoreapi
npm install
- Start the server:
npm run dev
This will start the Express server and you can access the API at http://localhost:3000.
The frontend part of the application is in index.html
and the script.mjs
file. It allows you to add books and view the list of books by interacting with the backend API.
GET /api/books
: Returns a list of books.
POST /api/books
: Allows you to add a new book (requires title and author in the body).
For local development, the app uses nodemon to auto-reload the server on changes:
npm run dev