Skip to content

ernitingarg/typescript-fastify-postgres-prisma-auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c8218d9 · Nov 5, 2023

History

16 Commits
Nov 4, 2023
Oct 29, 2023
Oct 29, 2023
Nov 5, 2023
Oct 29, 2023
Nov 4, 2023
Nov 4, 2023
Nov 4, 2023
Nov 4, 2023
Nov 5, 2023
Oct 26, 2023
Nov 5, 2023
Nov 5, 2023
Oct 30, 2023

Repository files navigation

typescript-fastify-auth-microservice

Prerequisites installation

Init

npm init -y
npx tsc --init

Dependencies

npm install fastify fastify-zod zod zod-to-json-schema @fastify/swagger @fastify/swagger-ui @fastify/jwt @prisma/client bcrypt
npm install pino pino-pretty

npm install @faker-js/faker tap ts-mock-imports

Dev Dependencies

npm install -D ts-node ts-node-dev typescript @types/node dotenv nodemon @types/bcrypt
npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm install -D @types/tap sinon

Prisma Initialization

npx prisma init --datasource-provider postgresql

Prisma db Migration

npx prisma migrate dev --name init

Launch prisma studio

npx prisma studio

healthcheck

Swagger documentation

http://localhost:5000/docs

Run docker locally

To run database directly inside container, please follow below steps:

  • Download docker

  • To change environment variables, please use .env file

  • Run db docker container and app

npm run start
  • Run database docker container
npm run start:db
  • To stop docker container
ctrl c
OR
docker-compose down

# To stop with data/volumne cleanup
docker-compose down -v --rmi all
  • To see containers logs
docker-compose logs postgres
  • To connect to Postgres database manually
 docker exec -it postgres bash
 psql -U admin -d postgresdb
  • To see all tables in database
\dt;