Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ernitingarg/typescript-fastify-postgres-prisma-auth-api
Auth api using nodejs, typescript, fastify, zod, prisma, postgres, tap
https://github.com/ernitingarg/typescript-fastify-postgres-prisma-auth-api
auth-api docker docker-compose fastify github-actions jwt-authentication nodejs pino postgresql postman prisma-orm tap typescript
Last synced: about 2 months ago
JSON representation
Auth api using nodejs, typescript, fastify, zod, prisma, postgres, tap
- Host: GitHub
- URL: https://github.com/ernitingarg/typescript-fastify-postgres-prisma-auth-api
- Owner: ernitingarg
- Created: 2023-10-24T13:20:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-05T09:45:54.000Z (about 1 year ago)
- Last Synced: 2024-11-07T01:16:33.801Z (about 2 months ago)
- Topics: auth-api, docker, docker-compose, fastify, github-actions, jwt-authentication, nodejs, pino, postgresql, postman, prisma-orm, tap, typescript
- Language: TypeScript
- Homepage:
- Size: 427 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# typescript-fastify-auth-microservice
## Prerequisites installation
### Init
```bash
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-prettynpm 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
- http://localhost:5000/api/health
- http://localhost:5000/api/health/db### Swagger documentation
http://localhost:5000/docs
## Run docker locally
To run database directly inside container, please follow below steps:
- Download docker
- [Windows](https://docs.docker.com/desktop/install/windows-install/)
- [Ubuntu](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)- To change environment variables, please use [.env](.env.example) file
- Run db docker container and app
```base
npm run start
```- Run database docker container
```bash
npm run start:db
```- To stop docker container
```bash
ctrl c
OR
docker-compose down# To stop with data/volumne cleanup
docker-compose down -v --rmi all
```- To see containers logs
```bash
docker-compose logs postgres
```- To connect to Postgres database manually
```bash
docker exec -it postgres bash
psql -U admin -d postgresdb
```- To see all tables in database
```bash
\dt;
```