https://github.com/sandundil2002/node-crud
This repository is a lightweight, web-based app for easy inventory management, featuring item CRUD operations with Node.js, MySQL, and Bootstrap.
https://github.com/sandundil2002/node-crud
bootstrap express-js html jquery mysql-database node-js
Last synced: 3 months ago
JSON representation
This repository is a lightweight, web-based app for easy inventory management, featuring item CRUD operations with Node.js, MySQL, and Bootstrap.
- Host: GitHub
- URL: https://github.com/sandundil2002/node-crud
- Owner: sandundil2002
- Created: 2024-11-05T03:49:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-05T06:11:11.000Z (over 1 year ago)
- Last Synced: 2025-02-22T06:11:34.643Z (over 1 year ago)
- Topics: bootstrap, express-js, html, jquery, mysql-database, node-js
- Language: JavaScript
- Homepage:
- Size: 1.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Node CRUD
This repository is a full-featured CRUD API built with Node.js and MySQL. This project provides a simple and efficient way to manage items with operations to Create, Read, Update, and Delete (CRUD) item records. The backend is built with Express, and the frontend uses HTML and Bootstrap.
Features
* REST API: Fully functional CRUD API with endpoints for managing items.
* Database: Uses MySQL to store and retrieve item data.
* Frontend: A simple HTML form with Bootstrap for interacting with the API.
* CORS Support: Configured to handle cross-origin requests.
* Scalable Structure: Industry-standard project structure for easy scalability and maintenance.
Prerequisites
* Node.js (version 14 or above)
* MySQL (version 5.7 or above)
* npm (usually installed with Node.js)
Getting Started
1. Clone the Repository
git clone https://github.com/sandundil2002/Node-CRUD.git
cd inventoryhub
2. Install Dependencies
npm install
3. Set Up the Database
CREATE DATABASE node_api;
CREATE TABLE items (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL);
4. Update db.js with your own mysql configurations
const pool = mysql.createPool({
host: "localhost", // Your MySQL server host (e.g., localhost)
user: "", // Your MySQL username
password: "", // Your MySQL password
database: "node_api", // The database name you want to connect
});
4. Test the API
npm run dev
You can test the API using Postman or similar tools. The available endpoints are:
* GET /api/items – Retrieve all items
* GET /api/items/:id – Retrieve an item by ID
* POST /api/items – Create a new item
* PUT /api/items/:id – Update an item by ID
* DELETE /api/items/:id – Delete an item by ID
API Documentation
* You can view the detailed API documentation with example requests and responses here.
Frontend
The project includes a simple frontend form to interact with the API. To use it, open public/index.html in a web browser and try adding, updating, or deleting items.