-
Notifications
You must be signed in to change notification settings - Fork 0
Db module #4
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
Db module #4
Changes from all commits
a8b9944
0b6cb3c
c09f0cb
dbd1e03
fe2a07d
ea9f389
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,41 @@ | ||
| # Dependencies | ||
| node_modules | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # Build | ||
| dist | ||
| *.tsbuildinfo | ||
|
|
||
| # Environment | ||
| .env | ||
| .env.example | ||
| Dockerfile | ||
| docker-compose.yaml | ||
| .env.* | ||
|
|
||
| # Testing | ||
| tests | ||
| coverage | ||
| .jest | ||
|
|
||
| # Documentation | ||
| docs | ||
| *.md | ||
|
|
||
| # Git | ||
| .git | ||
| .gitignore | ||
| .dockerignore | ||
|
|
||
| # Docker | ||
| Dockerfile | ||
| docker-compose* | ||
|
|
||
| # IDEs | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,38 @@ | ||
| # Dependencies | ||
| node_modules | ||
| /package-lock.json | ||
| /yarn.lock | ||
|
|
||
| # Build | ||
| dist | ||
| *.tsbuildinfo | ||
|
|
||
| # Environment | ||
| .env | ||
| .env.local | ||
| .env.*.local | ||
|
|
||
| # Prisma | ||
| /prisma/*.db | ||
| /prisma/*.db-journal | ||
| /src/generated/prisma | ||
|
|
||
| # Logs | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .pnpm-debug.log* | ||
|
|
||
| # Testing | ||
| coverage | ||
| .nyc_output | ||
|
|
||
| # IDEs | ||
| .vscode | ||
| .idea | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,35 @@ | ||||||||||||||||||
| FROM node:22-alpine3.20 | ||||||||||||||||||
| # Stage 1: Build | ||||||||||||||||||
| FROM node:22-alpine AS builder | ||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||
| COPY ./package.json ./yarn.lock ./ | ||||||||||||||||||
| RUN yarn | ||||||||||||||||||
|
|
||||||||||||||||||
| # Install dependencies needed for build | ||||||||||||||||||
| COPY package.json yarn.lock ./ | ||||||||||||||||||
| COPY prisma ./prisma/ | ||||||||||||||||||
| RUN yarn install --frozen-lockfile | ||||||||||||||||||
|
|
||||||||||||||||||
| # Copy source and build | ||||||||||||||||||
| COPY . . | ||||||||||||||||||
| RUN yarn build | ||||||||||||||||||
| CMD yarn start | ||||||||||||||||||
|
|
||||||||||||||||||
| # Stage 2: Runtime | ||||||||||||||||||
| FROM node:22-alpine AS runner | ||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||
|
|
||||||||||||||||||
| # Install runtime dependencies (openssl is required by Prisma on Alpine) | ||||||||||||||||||
| RUN apk add --no-cache openssl | ||||||||||||||||||
|
|
||||||||||||||||||
| # Set environment to production | ||||||||||||||||||
| ENV NODE_ENV=production | ||||||||||||||||||
|
|
||||||||||||||||||
| # Copy built artifacts and production dependencies | ||||||||||||||||||
| COPY --from=builder /app/package.json /app/yarn.lock ./ | ||||||||||||||||||
| COPY --from=builder /app/dist ./dist | ||||||||||||||||||
| COPY --from=builder /app/node_modules ./node_modules | ||||||||||||||||||
|
Comment on lines
+24
to
+27
|
||||||||||||||||||
| # Copy built artifacts and production dependencies | |
| COPY --from=builder /app/package.json /app/yarn.lock ./ | |
| COPY --from=builder /app/dist ./dist | |
| COPY --from=builder /app/node_modules ./node_modules | |
| # Copy package metadata and install only production dependencies | |
| COPY --from=builder /app/package.json /app/yarn.lock ./ | |
| RUN yarn install --production --frozen-lockfile | |
| COPY --from=builder /app/dist ./dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,63 @@ | ||
| version: '3.8' | ||
| services: | ||
|
|
||
| services: | ||
| postgres: | ||
| image: postgres:15 | ||
| image: postgres:15-alpine | ||
| container_name: postgres-db | ||
| restart: unless-stopped | ||
| ports: | ||
| - ${DB_EXPOSE_PORT}:5432 | ||
| - "${DB_EXPOSE_PORT:-5432}:5432" | ||
| environment: | ||
| - POSTGRES_USER=${FLEXIBASE_ADMIN_USER} | ||
| - POSTGRES_PASSWORD=${FLEXIBASE_ADMIN_PASSWORD} | ||
| - POSTGRES_DB=${DB_NAME} | ||
| POSTGRES_USER: ${FLEXIBASE_ADMIN_USER} | ||
| POSTGRES_PASSWORD: ${FLEXIBASE_ADMIN_PASSWORD} | ||
| POSTGRES_DB: ${DB_NAME} | ||
| volumes: | ||
| - postgres-data:/var/lib/postgresql/data | ||
| restart: unless-stopped | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U ${FLEXIBASE_ADMIN_USER} -d ${DB_NAME}"] | ||
| interval: 10s | ||
| test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| redis: | ||
| image: redis:alpine | ||
| container_name: flexibase-redis | ||
| restart: unless-stopped | ||
| ports: | ||
| - "6379:6379" | ||
| networks: | ||
| - flexibase-network | ||
| healthcheck: | ||
| test: ["CMD", "redis-cli", "ping"] | ||
| interval: 5s | ||
| timeout: 3s | ||
| retries: 5 | ||
|
|
||
| flexibase-db: | ||
| build: . | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| container_name: flexibase-db | ||
| restart: unless-stopped | ||
| ports: | ||
| - ${FLEXIBASE_DB_EXPOSE_PORT}:${FLEXIBASE_DB_EXPOSE_PORT} | ||
| - "${FLEXIBASE_DB_EXPOSE_PORT}:${FLEXIBASE_DB_EXPOSE_PORT}" | ||
| environment: | ||
| - FLEXIBASE_DB_EXPOSE_PORT=${FLEXIBASE_DB_EXPOSE_PORT} | ||
| - FLEXIBASE_ADMIN_USER=${FLEXIBASE_ADMIN_USER} | ||
| - FLEXIBASE_ADMIN_PASSWORD=${FLEXIBASE_ADMIN_PASSWORD} | ||
| - DB_EXPOSE_PORT=${DB_EXPOSE_PORT} | ||
| - DB_NAME=${DB_NAME} | ||
| - DB_HOST=postgres | ||
| - DATABASE_URL=postgresql://${FLEXIBASE_ADMIN_USER}:${FLEXIBASE_ADMIN_PASSWORD}@postgres:5432/${DB_NAME} | ||
| FLEXIBASE_DB_EXPOSE_PORT: ${FLEXIBASE_DB_EXPOSE_PORT} | ||
| FLEXIBASE_ADMIN_USER: ${FLEXIBASE_ADMIN_USER} | ||
| FLEXIBASE_ADMIN_PASSWORD: ${FLEXIBASE_ADMIN_PASSWORD} | ||
| DATABASE_URL: postgresql://${FLEXIBASE_ADMIN_USER}:${FLEXIBASE_ADMIN_PASSWORD}@postgres:5432/${DB_NAME} | ||
| REDIS_URL: redis://redis:6379 | ||
| depends_on: | ||
| postgres: | ||
| condition: service_healthy | ||
| restart: unless-stopped | ||
|
|
||
| redis: | ||
| condition: service_healthy | ||
| networks: | ||
| - flexibase-network | ||
|
|
||
| volumes: | ||
| postgres-data: | ||
|
|
||
| networks: | ||
| default: | ||
| name: flexibase-db-network | ||
| flexibase-network: | ||
| name: flexibase-network |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { JwtPayload } from "jsonwebtoken"; | ||
|
|
||
| declare global { | ||
| namespace Express { | ||
| interface Request { | ||
| user?: UserPayload; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export interface UserPayload extends JwtPayload { | ||
| id: string; | ||
| role: "ADMIN" | "USER"; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verifyUser controller now returns the user object with role information (line 12), but the response structure changed from returning just the id directly to returning a nested user object. This is a breaking API change that could affect existing clients.
Consider maintaining backward compatibility by including both formats, or clearly document this breaking change in the PR description or migration guide.