Skip to content

revou-fsse/our-backend

Repository files navigation

Our Backend: Productive

Productive is a backend web API service for productivity needs, especially like todos. Built using NestJS framework TypeScript starter repository.

Similar with:

  • Google Keep
  • Microsoft Todo
  • Todoist
  • Checklist in Notion
  • GitHub Issues

Links

Team

Name Role
First Name Lead and Backend Developer
Second Name Backend Developer and Database Admin
Third Name Backend Developer and Infra Engineer

API Documentation

Base API URLs:

Swagger:

Endpoints:

HTTP Endpoint Description
GET / Show welcome
POST /auth/register Register new user
POST /auth/login Login to user
GET /todos Get all todos
GET /todos/completed Get all completed todos
GET /todos/:id Get one todo by id
POST /todos Create new todo
PUT /todos/:id Update one todo by id
PATCH /todos/:id Update one todo by id
DELETE /todos Delete all todos
DELETE /todos/:id Delete one todo by id

Infra Architecture

diagram

Install dependencies

$ pnpm i

Prepare Database

Make sure the database is ready before doing any dependency installation. Edit .env file for the app if needed:

DATABASE_URL="postgres://the_user:the_password@the_hostname:5432/db"
JWT_SECRET="abdefghijklmnopqrstuvwxyzabcdefghi"
UNSPLASH_ACCESS_KEY="abdefghijklmnopqrstuvwxyzabcdefghi"
  • DATABASE_URL, can be retreived from local database instance/container
  • JWT_SECRET, recommended to generate with scripts/random.sh
  • UNSPLASH_ACCESS_KEY, get it from Unsplash Developer app portal

Run Docker on your machine and run Docker Compose that specifically only run the database instance in the background:

$ docker compose -f docker-compose.dev.yaml up -d

Install Dependencies

Install local dependencies:

$ pnpm i

Install global dependencies:

$ pnpm i -g @nestjs/cli
$ pnpm i -g prettier
$ pnpm i -g eslint

Check available scripts/commands:

$ pnpm run

Run for Development

Push or migrate schema to the database or generate Prisma schema while in development:

$ pnpm prisma:push
$ pnpm prisma:migrate
$ pnpm prisma:generate

Then we can run the app

# development with watch mode
$ pnpm dev

# development
$ pnpm start

# production mode
$ pnpm start:prod

Test

# unit tests
$ pnpm test

# e2e tests
$ pnpm test:e2e

# test coverage
$ pnpm test:cov

License

MIT License