gmazoni / 3t-plus

TTT Stack with additional features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App Web

Intro

Made with ❤️

TypeScript, Next.js, NextAuth.js, tailwindcss, tRPC, Zod, Prisma, trpc-openapi, superjson, BullMQ, Playwright

Install

Consider all the above steps to be done inside the dev container

Post Install

#for pre-commit hook (Optional, it avoids commiting code with lint errors)
npx husky install

Development server

# run development server
pnpm dev

Testing

When testing Prisma will use a separate database (test) from the development database. This is to prevent data loss when running tests. Each test will truncate the database tables before and after running automatically for Jest (Unit), for Playwright (E2E) you must do it manually.

# Run unit testes first (Jest) then run e2e tests (Playwright)
pnpm test

# Run unit tests only
pnpm test:unit

# Run e2e tests only
pnpm test:e2e

There is a factory folder for creating database records for testing. Take a look at @/factories. faker is used to generate random data.

Build

# build for production locally
pnpm build

# then, Start from build locally
pnpm start

Tools

Sign In

Add a new ADMIN user with Prisma studio, can be any valid email.

Use Mailcatcher (a local SMTP server with UI) http://localhost:1080 provided within docker-compose.yml to sign in.

Prisma

# Prisma Studio (UI for Prisma)
npx prisma studio

# Migration (After changing schema.prisma)
npx prisma migrate dev

# Migration Reset (Force reset database)
npx prisma migrate reset

More at: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-cli

Redis CLI

# Redis CLI
pnpm cache

Swagger and HTTP API

Authenticate on Swagger by generating a API key with Prisma Studio

key

Then, go to http://localhost:3000/swagger and paste the key on the Authorize button.

swagger

The key must be passed on the Authorization header when calling the API externally when an endpoint is protected.

 # curl example
 curl -X 'GET' \
  'http://localhost:3000/api/all' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer clflwni3q0001v20i6hmz0dvj'

About

TTT Stack with additional features.


Languages

Language:Shell 54.3%Language:TypeScript 38.6%Language:JavaScript 4.8%Language:Dockerfile 2.1%Language:CSS 0.1%