This repository contains the backend API for the ShelfLife application, a book tracking app built with the MERN (MongoDB, Express.js, React, Node.js) stack.
- Node.js and npm (or yarn) installed on your system.
- A MongoDB database (local or cloud-based).
- Clone the repository:
git clone https://github.com/blockchaincyberpunk1/shelflife-backend.git
- Navigate to the project directory:
cd shelflife-backend
- Install dependencies:
npm install
Create a .env
file in the root directory of the project and add the following environment variables:
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_strong_random_secret
PORT=your_desired_port (optional)
- Replace the placeholders with your actual values.
- Development Mode:
npm run dev // Uses nodemon to automatically restart the server on changes
- Production Mode:
(Make sure to build your app for production using
npm start
npm run build
before deploying.)
The following API endpoints are available:
Books:
GET /api/books
: Fetch all books.GET /api/books/shelf/:shelf
: Fetch books by shelf (replace:shelf
with the shelf name, e.g.,currentlyReading
).PUT /api/books/:id
: Update a book's shelf (replace:id
with the book's ID).POST /api/books
(optional): Add a new book.
Authentication (if implemented):
POST /api/auth/signup
: Create a new user account.POST /api/auth/login
: Log in a user.
To run the tests, execute the following command:
npm test
Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute to the project.