Skip to content

nyarachun/Events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Events Backend API

Overview

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.

Features

  • 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

Tech Stack

  • Node.js
  • NestJS
  • Prisma ORM
  • PostgreSQL (or compatible database)
  • Redis
  • Zod (validation)

Project Structure

src/
├── core/              # Infrastructure (database, redis)
├── common/            # Shared logic (guards, pipes, filters, utils)
├── modules/           # Feature modules (auth, users, events)
├── main.ts            # Application entry point

Installation

1. Clone the repository

git clone https://github.com/nyarachun/Events.git
cd Events

2. Install dependencies

npm install

3. Configure environment variables

Create a .env file in the root directory and define the required variables:

DATABASE_URL=
JWT_SECRET=
REDIS_HOST=
REDIS_PORT=

4. Run database migrations

npx prisma migrate dev

5. Start the application

npm run start:dev

API Overview

Authentication

  • POST /auth/register — register a new user
  • POST /auth/login — authenticate user and receive JWT

Users

  • GET /users — get all users (restricted)
  • GET /users/:id — get user by id

Events

  • 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

Validation

All incoming requests are validated using Zod schemas through a custom validation pipe. Invalid requests return structured error responses.


Authorization

The application uses JWT-based authentication along with role-based guards. Protected routes require a valid access token and appropriate user role.


Error Handling

A global exception filter ensures consistent error responses across the application.


Logging

Requests and responses are logged using middleware and interceptors for better observability.


About

Events Backend API is a server-side application built with NestJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors