https://github.com/uroobacodes/mern-bookstore-backend
This is the backend code for my mern bookstore frontend.
https://github.com/uroobacodes/mern-bookstore-backend
cors expressjs koyeb-api middlewares mongodb mongodb-atlas mongoose
Last synced: 3 months ago
JSON representation
This is the backend code for my mern bookstore frontend.
- Host: GitHub
- URL: https://github.com/uroobacodes/mern-bookstore-backend
- Owner: uroobaCodes
- Created: 2025-02-21T06:54:09.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-02-25T11:02:33.000Z (3 months ago)
- Last Synced: 2025-02-25T12:19:31.450Z (3 months ago)
- Topics: cors, expressjs, koyeb-api, middlewares, mongodb, mongodb-atlas, mongoose
- Language: JavaScript
- Homepage: https://variable-juliette-herw-b02b6054.koyeb.app/api/books
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MERN Bookstore - Backend
This is the backend for the MERN Bookstore, built with **Node.js**, **Express**, and **MongoDB**. It provides secure authentication, CRUD functionality, and API endpoints for managing books and user accounts.## Features
- JWT authentication & authorization
- CRUD operations for books
- User roles (Admin & Customers)
- RESTful API with Express.js
- MongoDB database integration
## 🛠️ Tech Stack



## 🔧 Installation & Setup
1️⃣**Clone this repo:**
```sh
git clone https://github.com/uroobaCodes/mern-bookstore-backend.git
cd mern-bookstore-backend
npm install
```
2️⃣ **Create .env file**- MONGO_URI=your_mongodb_connection_string
- JWT_SECRET=your_secret_key
- PORT=50003️⃣ **Start the server**
```sh
npm run dev
```
The backend should now be running on http://localhost:5000. I did use npm run dev for Backend as well because of using nodemon.#### Front-End Repo
This backend connects to a React + Zustand frontend. Follow the setup guide in the frontend repository:
[Front-end repo](https://github.com/uroobaCodes/mern-bookstore)### API Endpoints
| Method | Endpoint | Description | Auth Required |
|--------|--------------------|---------------------------------------|--------------|
| GET | `/api/books` | Fetch all books | ❌ No |
| GET | `/api/books/:id` | Fetch a single book by ID | ❌ No |
| GET | `/api/books/weekly-book`| Fetch a weekly book | ❌ No |
| POST | `/api/books/create-book` | Add a new book | ✅ Yes |
| PUT | `/api/books/edit/:id` | Update book details | ✅ Yes |
| DELETE | `/api/books/:id` | Delete a book | ✅ Yes |
| POST | `/api/auth/admin` | Admin Sign-in | ✅ Yes |
| GET | `/api/auth/admin` | Dashboard statistics using get request | ❌ No |
| POST | `/api/orders/create-order` | Post an order | ❌ No |
| GET | `/api/orders/email/:email` | Get orders by user's email | ❌ No |