https://github.com/subramanyamchoda/bookstore-api
Bookstore API is a RESTful service built with Node.js and Express that allows users to manage books with secure JWT-based authentication and JSON file-based storage. It supports user registration, login, and full CRUD operations on books.
https://github.com/subramanyamchoda/bookstore-api
backend bookstoreapp expressjs javascript json jwt-authentication node-js
Last synced: about 2 months ago
JSON representation
Bookstore API is a RESTful service built with Node.js and Express that allows users to manage books with secure JWT-based authentication and JSON file-based storage. It supports user registration, login, and full CRUD operations on books.
- Host: GitHub
- URL: https://github.com/subramanyamchoda/bookstore-api
- Owner: subramanyamchoda
- Created: 2025-07-02T15:28:25.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-02T16:01:36.000Z (12 months ago)
- Last Synced: 2025-07-02T16:45:04.652Z (12 months ago)
- Topics: backend, bookstoreapp, expressjs, javascript, json, jwt-authentication, node-js
- Language: JavaScript
- Homepage: https://bookstore-api-k7a3.onrender.com/
- Size: 933 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ Bookstore API
A simple REST API for managing books using **Node.js**, **Express**, and **JSON file storage**.
This app includes:
* ๐ User Registration & Login
* ๐ก๏ธ JWT Authentication
* ๐ Book CRUD operations
* ๐ Search by Genre
* ๐ Pagination
* ๐งพ Token-based access control
---
## ๐ Live URL: [https://bookstore-api-k7a3.onrender.com](https://bookstore-api-k7a3.onrender.com)
Use this URL as the base for all API requests.
---
## ๐ฌ API Endpoints (Ready for Postman)
**Base URL:** `http://localhost:5000`
---
## โ
User Authentication
### ๐ Register
**POST** `/users/register`
**Request Body:**
```json
{
"email": "subbu@gmail.com",
"password": "subbu"
}
```
### ๐ Login
**POST** `/users/login`
**Request Body:**
```json
{
"email": "subbu@gmail.com",
"password": "subbu"
}
```
**Response Example:**
```json
{
"message": "Login successful",
"token": ""
}
```
Copy the token and use it in the **Authorization header** for all `/books` routes:
```
Authorization: Bearer
```
---
## ๐ Book Routes (Protected with JWT)
*All routes below require an auth token.*
### โ Add Book
**POST** `/books`
**Headers:**
```
Authorization: Bearer
```
**Request Body:**
```json
{
"title": "Node.js Design Patterns",
"author": "Mario Casciaro",
"genre": "Programming",
"publishedYear": 2020
}
```
---
### ๐ Get All Books (with Pagination)
**GET** `/books?page=1&limit=5`
**Response:**
```json
{
"total": 2,
"page": 1,
"limit": 5,
"books": [
{
"id": "36a84b45-1ac7-476b-a0d7-a9cb4af872ad",
"title": "Node.js Design Patterns",
"author": "Mario Casciaro",
"genre": "Programming",
"publishedYear": 2020,
"userId": "13669048-6d2b-4f8e-8991-98ef4a1d935b"
}
]
}
```
---
### ๐ Search Books by Genre
**GET** `/books/search?genre=Programming`
---
### ๐ Get Book by ID
**GET** `/books/:id`
*Example:* `/books/36a84b45-1ac7-476b-a0d7-a9cb4af872ad`
---
### โ๏ธ Update Book
**PUT** `/books/:id`
**Headers:**
```
Authorization: Bearer
```
**Request Body:**
```json
{
"title": "Node Design Patterns",
"author": "Mario Casciaro",
"genre": "Programming",
"publishedYear": 2021
}
```
---
### ๐๏ธ Delete Book
**DELETE** `/books/:id`
**Headers:**
```
Authorization: Bearer
```
---
## ๐ Setup Instructions
### ๐ Clone the Repository
```bash
git clone https://github.com/subramanyamchoda/bookstore-api.git
cd bookstore-api
```
### ๐ฆ Install Dependencies
```bash
npm install
```
### ๐ Environment Variables
Create a `.env` file in the root directory:
```ini
SECRET_KEY=your_secret_key_here
PORT=5000
```
### โถ๏ธ Run the Server
```bash
npm start
```
API will be running at:
๐ `http://localhost:5000`
---
## ๐ Tech Stack
* Node.js
* Express.js
* JWT (jsonwebtoken)
* bcryptjs
* uuid
* File system (JSON file storage)
* Postman (API testing)
---
## โ
Features
* ๐ Secure User Registration & Login
* ๐ก JWT-based Protected Routes
* ๐ Full Book Management (Create, Read, Update, Delete)
* ๐ Search Books by Genre
* ๐ Pagination for Book Listings
* ๐ค Only the user who created a book can update/delete it
---
## ๐ธ Postman Testing Screenshots
| Register | Login |
| -------------------------------------------- | ----------------------------------------- |
|
|
|
| Add Book | Get All Books |
| ------------------------------------------- | ----------------------------------------------- |
|
|
|
| Single Book | Update Book | Delete Book |
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
|
|
|
|
---
## ๐ Reach me
**Subramanyam Choda**
๐ง [Email](mailto:your-email@example.com)
๐ [GitHub](https://github.com/subramanyamchoda)