Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion flexibase-auth/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,19 @@ const limiter = rateLimit({

app.use(limiter);

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use("/api/auth/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use("/api", rootRouter);

/**
* @openapi
* /auth/service-check:
* get:
* summary: Service health check
* tags: [Utility]
* responses:
* 200:
* description: Service is available
*/
app.get("/api/auth/service-check", (_, res) => {
res.json({ isServiceAvailable: true });
});
Expand Down
6 changes: 3 additions & 3 deletions flexibase-auth/src/config/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const options = {
},
servers: [
{
url: "http://localhost:3000/api",
description: "Local server",
url: "/api",
description: "API Base Path",
},
],
components: {
Expand All @@ -24,7 +24,7 @@ const options = {
},
},
},
apis: ["./src/routers/*.ts"], // Files containing annotations
apis: ["./src/routers/*.ts", "./src/app.ts"], // Files containing annotations
};

export const swaggerSpec = swaggerJsdoc(options);
4 changes: 2 additions & 2 deletions flexibase-auth/src/controllers/auth/verifyUser.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export const verifyUserController = (req: Request, res: Response) => {
if (!req.user) {
throw new AppError("Unauthorized", 401);
}
const { id } = req.user;
const { id, role } = req.user;

res.json({
isSuccess: true,
Copy link

Copilot AI Jan 27, 2026

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.

Suggested change
isSuccess: true,
isSuccess: true,
id,

Copilot uses AI. Check for mistakes.
id,
user: { id, role },
});
};
39 changes: 36 additions & 3 deletions flexibase-db/.dockerignore
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
33 changes: 33 additions & 0 deletions flexibase-db/.gitignore
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
36 changes: 32 additions & 4 deletions flexibase-db/Dockerfile
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 link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime stage copies all node_modules from the builder stage (line 27), which includes both production and development dependencies. This increases the image size and attack surface unnecessarily.

After copying from builder, run yarn install --production --frozen-lockfile in the runner stage to install only production dependencies, or use yarn workspaces focus --production if using workspaces.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
COPY --from=builder /app/prisma ./prisma

# Use a non-root user for security (Node.js alpine image comes with 'node' user)
USER node

EXPOSE ${FLEXIBASE_DB_EXPOSE_PORT}

CMD ["node", "dist/app.js"]
62 changes: 40 additions & 22 deletions flexibase-db/docker-compose.yaml
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
14 changes: 14 additions & 0 deletions flexibase-db/index.d.ts
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";
}
16 changes: 14 additions & 2 deletions flexibase-db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,30 @@
"dev": "nodemon ./src/app.ts",
"build": "prisma generate && tsc -p .",
"start": "node ./dist/app.js",
"test": "DATABASE_URL=postgres://u:p@h:5432/d FLEXIBASE_ADMIN_USER=a FLEXIBASE_ADMIN_PASSWORD=p jest --setupFilesAfterEnv ./tests/setup.ts",
"postinstall": "prisma generate"
},
"dependencies": {
"@prisma/client": "^7.3.0",
"@types/csv-parse": "^1.1.12",
"@types/dotenv": "^8.2.3",
"@types/json2csv": "^5.0.7",
"@types/multer": "^2.0.0",
"@types/redis": "^4.0.10",
"axios": "^1.13.3",
"cors": "^2.8.6",
"csv-parse": "^6.1.0",
"dotenv": "^17.2.3",
"express": "^5.2.1",
"express-rate-limit": "^8.2.1",
"helmet": "^8.1.0",
"json2csv": "^6.0.0-alpha.2",
"multer": "^2.0.2",
"prisma": "^7.3.0",
"redis": "^5.10.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"uuid": "^9.0.1",
"winston": "^3.19.0",
"zod": "^4.3.6"
},
Expand All @@ -32,13 +45,12 @@
"@types/supertest": "^6.0.3",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.8",
"@types/uuid": "^9.0.8",
"@types/winston": "^2.4.4",
"jest": "^30.2.0",
"jest-mock-extended": "^4.0.0",
"nodemon": "^3.1.11",
"supertest": "^7.2.2",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
Expand Down
Loading
Loading