Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Prisma as our ORM (Object-Relational Mapper) #21

Merged
merged 30 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eb0455d
enh: install prisma
marco-souza May 18, 2023
f2e944a
fea: setup prisma
marco-souza May 18, 2023
14ee29e
fea: modeling prisma data
marco-souza May 18, 2023
f0a4bc9
fea: add diagram generator
marco-souza May 19, 2023
eb63ad9
fea: use custom .env.local file
marco-souza May 19, 2023
abb9b15
fea: migration init
marco-souza May 19, 2023
0e5dd29
fix: generate erd as markdown
marco-souza May 20, 2023
006fe18
enh: ignore .env files
marco-souza May 20, 2023
dc62936
fix: update db initial migration
marco-souza May 20, 2023
bb613c2
fea: setup docker to run app & db
marco-souza May 20, 2023
19e8f49
fix: ignore all .env files
marco-souza May 21, 2023
2c02f2b
fix: update env example
marco-souza May 21, 2023
3a32cba
fea: add vscode db connection
marco-souza May 30, 2023
5fcbcc0
enh: cleanup prisma configs
marco-souza May 30, 2023
96266b4
enh: improve docker setup
marco-souza May 30, 2023
0fa55f6
enh: share credentials between app and db
marco-souza May 30, 2023
3833175
enh: add utils commands
marco-souza May 30, 2023
1e66ace
enh: update dependencies
marco-souza May 30, 2023
64b7ece
fix: docker ignore node_modules
marco-souza May 30, 2023
7d933dc
fea: setup jest for testing
marco-souza May 30, 2023
d0537d7
fea: setup test container
marco-souza May 30, 2023
76cc5b1
fea: test get user by username
marco-souza May 30, 2023
72e6445
enh: improve npm scripts for docker
marco-souza May 30, 2023
4a6a27b
fix: docker networking issue
marco-souza May 30, 2023
8a7173d
fix: id creation for users
marco-souza May 30, 2023
685f9c1
fea: add test for getting users tasks
marco-souza May 30, 2023
0733f7e
fea: add test users doing a task
marco-souza May 30, 2023
f16cda9
fea: add test for getting dependent tasks
marco-souza May 30, 2023
6519e59
enh: make username unique
marco-souza May 30, 2023
d5adf93
fea: add test case for adding repeated username
marco-souza May 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Next Auth
NEXTAUTH_SECRET=mypassword
NEXTAUTH_URL="http://localhost:3000" # dev only
NEXTAUTH_URL_INTERNAL="http://localhost:3000" # dev only

# Google credentials
GOOGLE_CLIENT_ID=*****
GOOGLE_CLIENT_SECRET=*****

# Github credentials
GITHUB_CLIENT_ID=*****
GITHUB_CLIENT_SECRET=*****

# Postgres
POSTGRES_USER="podcodar"
POSTGRES_HOST="localhost"
marco-souza marked this conversation as resolved.
Show resolved Hide resolved
POSTGRES_PASSWORD="my-password"
POSTGRES_DATABASE="podcodar-app-db"
POSTGRES_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DATABASE}"

# Prisma
POSTGRES_PRISMA_URL="${POSTGRES_URL}?pgbouncer=true&connect_timeout=15"
POSTGRES_URL_NON_POOLING=$POSTGRES_URL
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.env*
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:lts-alpine

WORKDIR /app

COPY package.json pnpm-lock* ./

# install pnpm and project dependencies
RUN npm i -g npm && \
npm i -g pnpm && \
pnpm i
marco-souza marked this conversation as resolved.
Show resolved Hide resolved

COPY . .

# startup command
CMD pnpm dev & pnpm db:studio
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3"

services:
app:
build: .
env_file: .env.development
marco-souza marked this conversation as resolved.
Show resolved Hide resolved
ports:
- "3000:3000" # app
- "5555:5555" # studio
volumes:
- .:/app
depends_on:
- db

db:
image: postgres
env_file: .env.development
ports:
- "5432:5432"

networks:
default:
name: podcodar-app
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"lint-staged": "lint-staged",
"lint": "next lint",
"analyze": "ANALYZE=true yarn build",
"db:generate": "prisma generate",
"db:migrate": "dotenv -e .env.local prisma migrate",
"db:studio": "dotenv -e .env.local prisma studio",
"prepare": "husky install"
},
"dependencies": {
Expand All @@ -28,12 +31,17 @@
"typescript": "5.0.2"
},
"devDependencies": {
"@mermaid-js/mermaid-cli": "^10.1.0",
"@podcodar/eslint-config-next": "^1.6.0",
"autoprefixer": "^10.4.14",
"dotenv-cli": "^7.2.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"postcss": "^8.4.23",
"prettier": "^2.8.8",
"tailwindcss": "^3.3.2"
"prisma": "^4.14.1",
"prisma-erd-generator": "^1.7.0",
"tailwindcss": "^3.3.2",
"ts-node": "^10.9.1"
}
}
Loading