Skip to content

Repository files navigation

Armenia Service Map Backend

NestJS + Prisma backend for the Armenia Service Map project.

Stack

  • NestJS 11
  • Prisma 7.5 + PostgreSQL
  • JWT auth (access + refresh)
  • MinIO/S3 presigned uploads
  • SMTP email delivery (Mailcatcher in development)

Prerequisites

  • Node.js 22+
  • npm 10+
  • PostgreSQL available locally

Environment Setup

  1. Install dependencies:
npm install
  1. Copy and edit env values:
cp .env.example .env

Required env variables include:

  • DATABASE_URL
  • JWT_ACCESS_SECRET, JWT_REFRESH_SECRET
  • S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET, S3_REGION
  • UPLOAD_MAX_IMAGE_BYTES, UPLOAD_MAX_DOCUMENT_BYTES
  • MAIL_HOST, MAIL_PORT, MAIL_FROM
  • PORT, CORS_ORIGIN
  • AUTO_DB_INIT controls startup DB initialization (default enabled; set AUTO_DB_INIT=false to disable)

Database Workflow (Development)

Apply the current migration set and seed data:

npx prisma migrate reset --force
npx prisma db seed

Cloud Auto Initialization (Optional)

By default, startup DB initialization is enabled. You can disable it with:

AUTO_DB_INIT=false

At startup, the backend will:

  1. Run prisma migrate deploy
  2. Check users table row count
  3. Run prisma db seed only when count is 0

This prevents reseeding on normal restarts once users already exist.

Check migration status:

npx prisma migrate status

Run the API

npm run start:dev

API base URL (default): http://localhost:3000/api

Seeded Credentials (Development)

All seeded users use password admin123:

  • Super admin: admin@refugeesupport.am
  • Org admin: org-admin@refugeesupport.am
  • Org member (pending): org-member@refugeesupport.am

Verification Commands

Build and tests:

npm run build
npm test
npm run test:e2e

Focused e2e suites for the backend foundation upgrade:

npm run test:e2e -- test/schema-foundation.e2e-spec.ts
npm run test:e2e -- test/auth-status.e2e-spec.ts
npm run test:e2e -- test/org-onboarding.e2e-spec.ts
npm run test:e2e -- test/needs-timeline-notifications.e2e-spec.ts
npm run test:e2e -- test/notifications-api.e2e-spec.ts
npm run test:e2e -- test/seed-smoke.e2e-spec.ts

Notes

  • E2E tests in test/*.e2e-spec.ts are implemented with pg integration queries for stable execution in this Jest environment.
  • The backend follows the layered structure: api -> usecases -> modules -> infrastructure.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages