Welcome to the Online Store RESTful API! This project provides a comprehensive backend for managing an online store, built using Bun, Hono, and SQLite. It includes features for product management, user registration and login, shopping cart management, and order processing.
- Product Management: Perform CRUD operations with support for pagination, filtering, and sorting.
- User Management: Register, login using JWT, and update user profiles.
- Shopping Cart: Add, update, and remove items from the shopping cart.
- Order Processing: Create and manage orders from the shopping cart, with stock validation and price calculations.
- Versioning: All endpoints are versioned under
/api/v1/.
- Backend Framework: Hono
- Database: SQLite (using Bun's built-in sqlite3)
- Authentication: JWT (via jsonwebtoken)
Before you begin, ensure you have met the following requirements:
To set up the project, follow these steps:
-
Clone the repository:
git clone https://github.com/Alsadig-ahmed/online-store-api.git cd online-store-api -
Install dependencies:
pnpm install
-
Set up environment variables:
Create a
.envfile in the root directory and add your configuration variables. -
Run the server:
bun run index.ts
After setting up, you can interact with the API using tools like Postman or cURL. Below are some example endpoints:
- GET /api/v1/products: Retrieve a list of products.
- POST /api/v1/users/register: Register a new user.
- POST /api/v1/users/login: Login and receive a JWT token.
- POST /api/v1/cart: Add an item to the cart.
- POST /api/v1/orders: Create an order from the items in the cart.