Events Backend API is a server-side application built with NestJS. It provides a RESTful API for managing users, authentication, and events. The project follows a modular architecture and applies common backend best practices such as role-based authorization, request validation, and centralized error handling.
- User registration and authentication using JWT
- Role-based access control (RBAC)
- CRUD operations for events
- Input validation using Zod
- Global exception handling
- Request logging via middleware and interceptors
- Database integration using Prisma ORM
- Redis integration for caching and performance optimization
- Node.js
- NestJS
- Prisma ORM
- PostgreSQL (or compatible database)
- Redis
- Zod (validation)
src/
├── core/ # Infrastructure (database, redis)
├── common/ # Shared logic (guards, pipes, filters, utils)
├── modules/ # Feature modules (auth, users, events)
├── main.ts # Application entry point
git clone https://github.com/nyarachun/Events.git
cd Events
npm install
Create a .env file in the root directory and define the required variables:
DATABASE_URL=
JWT_SECRET=
REDIS_HOST=
REDIS_PORT=
npx prisma migrate dev
npm run start:dev
- POST /auth/register — register a new user
- POST /auth/login — authenticate user and receive JWT
- GET /users — get all users (restricted)
- GET /users/:id — get user by id
- POST /events — create event
- GET /events — get all events
- GET /events/:id — get event by id
- PATCH /events/:id — update event
- DELETE /events/:id — delete event
All incoming requests are validated using Zod schemas through a custom validation pipe. Invalid requests return structured error responses.
The application uses JWT-based authentication along with role-based guards. Protected routes require a valid access token and appropriate user role.
A global exception filter ensures consistent error responses across the application.
Requests and responses are logged using middleware and interceptors for better observability.