-
Clone the repository
git clone cd backend-gesa
-
Install dependencies
npm install
-
Configure environment variables
-
Create a
.env
file in the root directory -
Add the following content
JWT_SECRET=your_jwt_secret DATABASE = 'marketplace' DATABASE_USERNAME = 'username' DATABASE_PASSWORD = 'password' DATABASE_HOST = 'localhost' DATABASE_PORT = 3306 DATABASE_TYPE = 'mysql' DATABASE_LOGGING = false
-
-
Setup the database
- Create a MySQL database named
marketplace
- Configure your database credentials in
.env
- Create a MySQL database named
-
Start the server
npm run start
POST /api/auth/register Body: { "username": "merchant1", "password": "password", "role": "merchant" }
POST /api/auth/login Body: { "username": "merchant1", "password": "password" }
POST /api/products Headers: { "Authorization": "Bearer your_jwt_token" } Body: { "name": "Product A", "price": 20000 }
GET /api/products
PUT /api/products/:id Headers: { "Authorization": "Bearer your_jwt_token" } Body: { "name": "Product A Updated", "price": 25000 }
DELETE /api/products/:id Headers: { "Authorization": "Bearer your_jwt_token" }
POST /api/transactions Headers: { "Authorization": "Bearer your_jwt_token" } Body: { "productId": 1, "quantity": 3 }
GET /api/transactions/merchant Headers: { "Authorization": "Bearer your_jwt_token" }
- Import the provided
postman_collection.json
into Postman to quickly test the endpoints.