This repository is a Node.js Express API built as a learning project to understand how to create a backend system for a restaurant management application. The API includes features like authentication, restaurant management, item management, and order management. It uses Prisma as the ORM and PostgreSQL as the database.
- Authentication: User registration and login with JWT-based authentication.
- Restaurant Management: Create, read, update, and delete restaurants.
- Item Management: Manage items within restaurants, including creating, reading, updating, and deleting items.
- Order Management: Handle customer orders, including creating, assigning, and confirming orders.
- Role-Based Access Control: Middleware to ensure only users with specific roles can access certain endpoints.
- Node.js: JavaScript runtime environment.
- Express: Web framework for Node.js.
- Prisma: ORM for database management.
- PostgreSQL: Relational database.
- TypeScript: Superset of JavaScript for type safety.
- JWT: JSON Web Tokens for authentication.
- Nodemailer: For sending emails.
- Swagger: API documentation.
- backend
- node_modules
- prisma
- src
- controllers
- services
- configs
- db
- interfaces
- middlewares
- routes
- utils
- index.ts
- .env
- Node.js
- PostgreSQL
-
Clone the repository:
git clone https://github.com/yourusername/restaurant-management-api.git cd restaurant-management-api/backend
-
Install dependencies:
npm install
-
Set up environment variables:
- Copy .env.example to
.env
and fill in the required values.
- Copy .env.example to
-
Run database migrations:
npx prisma migrate dev
-
Seed the database:
npm run seed
-
Start the development server:
npm run dev
API documentation is available at http://localhost:8888/api/v1/docs
when the server is running.
npm run dev
: Start the development server with nodemon.npm run seed
: Seed the database with initial data.
- ENV: Environment (e.g., DEV, PROD).
- PORT: Port number for the server.
DATABASE_URL
: PostgreSQL database connection string.- JWT_ACCESS_TOKEN_SECRET: Secret key for JWT access tokens.
- JWT_REFRESH_TOKEN_SECRET: Secret key for JWT refresh tokens.
- ADMIN_EMAIL_USER: Email user for sending emails.
- ADMIN_EMAIL_PASS: Email password for sending emails.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
For any inquiries, please contact 202300148@my.apiu.edu.