This project is a RESTful API for a pizza shop, built using Node.js, Express, and MongoDB. It provides endpoints to manage users and pizzas, including functionalities for registration, login, and CRUD operations for pizzas.
- User Registration
- User Login
- CRUD operations for pizzas
- Secure authentication with JWT
- Data validation
-
Clone the repository:
git clone https://github.com/mhistiak3/Pizza-Shop-REST-API.git
-
Navigate to the project directory:
cd Pizza-Shop-REST-API
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add your MongoDB URI and JWT secret:DB_URL=your_mongodb_uri JWT_SECRET=your_jwt_secret APP_PORT=your_app_port REFRESH_SECRET=your_refresh_secret APP_URL=your_app_url
-
Start the server:
npm start
Once the server is running, you can use an API client like Postman to test the endpoints.
- Register a user:
POST /api/register
- Login a user:
POST /api/login
- Logout a user:
POST /api/logout
- Who am I:
GET /api/me
- Refresh Token:
GET /api/refresh
- Add a new pizza:
POST /api/products
- Update a pizza:
PUT /api/products/:id
- Get all pizzas:
GET /api/products
- Get a single pizza:
GET /api/products/:id
- Delete a pizza:
DELETE /api/products/:id
- Node.js
- Express
- MongoDB
- Mongoose
- JSON Web Token (JWT)
- bcryptjs
- dotenv
- joi
- multer
- esm
Contributions are welcome! Please fork the repository and create a pull request.