This is the backend server for the eStore application, built with Express.js and TypeScript. The server provides RESTful API endpoints to support the eStore frontend application.
- Node.js
- Express.js (v4.21.2)
- TypeScript (v5.7.2)
- MySQL2 (v3.12.0)
- JSON Web Token (v9.0.2)
- bcryptjs (v3.0.2)
- CORS (v2.8.5)
- Node.js (Latest LTS version recommended)
- npm package manager
- MySQL database
- Clone the repository:
git clone https://github.com/timothyguo86/eStore.git
cd eStore-server- Install dependencies:
npm install- Configure environment variables:
Create a
.envfile in the root directory and add the following variables:
PORT=3000
DB_HOST=localhost
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_NAME=estore_db
JWT_SECRET=your_jwt_secretnodemon index.jsnpm run build
npm start- POST
/api/auth/register- Register a new user - POST
/api/auth/login- Login user
- GET
/api/products- Get all products - GET
/api/products/:id- Get product by ID - POST
/api/products- Create new product (Protected) - PUT
/api/products/:id- Update product (Protected) - DELETE
/api/products/:id- Delete product (Protected)
- JWT authentication
- Password hashing using bcryptjs
- CORS enabled
- Input validation and sanitization
The application uses MySQL as the database. Make sure to:
- Create a MySQL database
- Configure the connection in the environment variables
- Run migrations (if applicable)