Getting Started

Getting Started

Set up the User Management API in minutes.

1

Prerequisites

Node.js 18+PostgreSQLnpm or yarn
2

Installation

# Clone repository
git clone <repo-url>
cd users_management_backend

# Install dependencies
cd backend && npm install
3

Configuration

# Copy environment template
cp .env.example .env

# Edit .env with your values:
DATABASE_URL="postgresql://user:pass@host:5432/db"
JWT_ACCESS_SECRET="your-secret-min-32-chars"
JWT_REFRESH_SECRET="your-refresh-secret"
PORT=5001
4

Database Setup

# Run migrations
npm run db:migrate

# Seed default roles (admin, moderator, user)
npm run db:seed
5

Start Server

# Development mode with hot reload
npm run dev

# Production build
npm run build && npm start

Server runs at http://localhost:5001

6

Test the API

# Health check
curl http://localhost:5001/health

# Register a user
curl -X POST http://localhost:5001/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"test@test.com","username":"testuser","password":"Test123!"}'

Available Scripts

npm run devStart development server
npm run buildBuild for production
npm run startStart production server
npm run db:migrateRun database migrations
npm run db:seedSeed default data
npm run db:studioOpen Prisma Studio
npm run testRun tests
npm run lintRun ESLint