Repository navigation
Releases: Bardolog1/Basic-API-Express-Store
Releases · Bardolog1/Basic-API-Express-Store
Release list
v1.0.0
Express API with MySQL2 🎉
This is a simple CRUD API built with Express.js and MySQL2 for managing products, invoices, and inventory. 🚀
Features ✨
- 🌐 RESTful API with organized structure.
- 📄 Models, Repositories, and Services for clean separation of concerns.
- 🛡️ Middleware for validation and error handling.
- 🗄️ MySQL2 integration for database operations.
- 🧪 Ready for testing and scaling.
Prerequisites 📋
- Node.js (v14 or higher).
- MySQL/MariaDB setup (e.g., via XAMPP or Docker).
- A
.envfile configured with the following:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=store
PORT=3000Installation 🛠️
-
Clone the repository:
git clone https://github.com/Bardolog1/Basic-API-Express-Store.git cd Basic-API-Express-Store -
Install dependencies:
npm install
-
Configure the
.envfile. -
Initialize the database:
- Create a database named
store(or use the name specified in your.env). - Run the provided SQL scripts to create tables (
products,invoices,inventory).
- Create a database named
Usage 🚀
Start the Server
npm startThe server will run on http://localhost:3000 by default.
Endpoints 📡
-
Products:
GET /api/products: Retrieve all products.GET /api/products/:id: Retrieve a product by ID.POST /api/products: Add a new product.PUT /api/products/:id: Update a product by ID.DELETE /api/products/:id: Delete a product by ID.
-
Invoices:
GET /api/invoices: Retrieve all invoices.GET /api/invoices/:id: Retrieve an invoice by ID.POST /api/invoices: Add a new invoice.PUT /api/invoices/:id: Update an invoice by ID.DELETE /api/invoices/:id: Delete an invoice by ID.
-
Inventory:
GET /api/inventory: Retrieve all inventory items.GET /api/inventory/:id: Retrieve inventory details by ID.GET /api/inventory/product/:productId: Retrieve inventory by product ID.POST /api/inventory: Add a new inventory item.PUT /api/inventory/:id: Update inventory by ID.
Project Structure 🗂️
project-root
├── src
│ ├── config
│ │ └── db.config.js # Database configuration
│ ├── controllers # Route controllers
│ ├── middlewares # Middleware functions
│ ├── models # Entity definitions
│ ├── repositories # Database query logic
│ ├── routes # API route definitions
│ ├── errors # Custom error classes
│ └── services # Business logic
├── app.js # Express app configuration
├── server.js # Application entry point
└── README.md # Project documentation
Contributing 🤝
- Fork the repository.
- Create your feature branch:
git checkout -b feature-name. - Commit your changes:
git commit -m 'Add some feature'. - Push to the branch:
git push origin feature-name. - Submit a pull request.
License 📜
This project is licensed under the MIT License. See the LICENSE file for details.
Made with ❤️ by Bardolog1 ✨
Full Changelog: https://github.com/Bardolog1/Basic-API-Express-Store/commits/1.0.0