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
99 changes: 99 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Backend CI Pipeline

on:
push:
branches: [ main ]
paths:
- 'backend/**'
pull_request:
branches: [ main ]
paths:
- 'backend/**'

jobs:
backend-ci:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
backend/node_modules
backend/.bun
~/.bun/install/cache
backend/prisma/generated
key: ${{ runner.os }}-bun-${{ hashFiles('backend/bun.lock', 'backend/package.json', 'backend/tsconfig.json') }}
restore-keys: |
${{ runner.os }}-bun-

- name: Install dependencies
working-directory: ./backend
run: bun install

- name: Generate Prisma client
working-directory: ./backend
run: bunx prisma generate
env:
DATABASE_URL: postgresql://postgres:1234@localhost:5432/test_db

- name: Code quality check (Biome)
working-directory: ./backend
run: bun run check

- name: Type checking
working-directory: ./backend
run: bun run typecheck

- name: Run database migrations
working-directory: ./backend
run: bunx prisma migrate deploy
env:
DATABASE_URL: postgresql://postgres:1234@localhost:5432/test_db

- name: Security audit
working-directory: ./backend
run: bun audit

- name: Build application
working-directory: ./backend
run: bun run build

- name: Build verification
working-directory: ./backend
run: |
# Verify the built application can start without errors
timeout 10s bun dist/index.js || true

- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-build-artifacts
path: |
backend/dist/
backend/prisma/generated/
retention-days: 7
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules/

# Build and distribution output
/dist
backend/dist/
/dist-ssr
/build
/out
Expand Down
6 changes: 2 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

bunx lint-staged
#!/usr/bin/env sh
npx --no -- lint-staged
20 changes: 20 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
node_modules/

# Build outputs
dist/
build/

# Environment variables
.env
.env.*

# Logs
*.log

# Coverage
coverage/

# Temporary files
*.tmp
*.temp
15 changes: 10 additions & 5 deletions backend/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": true
"ignoreUnknown": true,
"includes": ["src/**"]
},
"formatter": {
"enabled": true,
Expand All @@ -19,16 +20,20 @@
"correctness": {
"noUnusedImports": "error",
"noUnusedVariables": "error"
},
"style": {
"noNonNullAssertion": "off"
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
},
"globals": [
"Bun"
]
"globals": ["Bun"]
},
"assist": {
"enabled": true,
Expand Down
7 changes: 2 additions & 5 deletions backend/bruno/bruno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
"version": "1",
"name": "formEngine",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}
"ignore": ["node_modules", ".git"]
}
64 changes: 36 additions & 28 deletions backend/bun.lock

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:

postgres:
image: postgres:17-alpine
container_name: formEngine-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 1234
POSTGRES_DB: postgres
ports:
- "5432:5432"
restart: on-failure
networks:
- app_network
volumes:
- postgres_data:/var/lib/postgresql/data

drizzle-gate:
image: ghcr.io/drizzle-team/gateway:latest
container_name: formEngine-drizzle-gateway
environment:
DATABASE_URL: postgresql://postgres:1234@postgres:5432/postgres
STORE_PATH: /app
restart: on-failure
depends_on:
- postgres
ports:
- "4983:4983"
volumes:
- drizzle_gateway_data:/app
networks:
- app_network

volumes:
postgres_data:
drizzle_gateway_data:

networks:
app_network:
21 changes: 13 additions & 8 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
"scripts": {
"dev": "bun --watch src/index.ts",
"check": "biome check .",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"build": "bun build src/index.ts --outdir dist --target bun --minify"
},
"dependencies": {
"@elysiajs/cors": "^1.4.1",
"@prisma/adapter-pg": "^7.3.0",
"@prisma/client": "^7.3.0",
"better-auth": "^1.4.12",
"elysia": "^1.0.0",
"pg": "^8.17.2",
"pino": "^10.1.1"
"better-auth": "^1.4.18",
"elysia": "^1.4.22",
"pg": "^8.18.0",
"pino": "^10.3.0"
},
"devDependencies": {
"@biomejs/biome": "^2.3.11",
"@biomejs/biome": "^2.3.13",
"@types/bun": "latest",
"@types/pg": "^8.16.0",
"pino-pretty": "^13.1.3",
"prisma": "7.3.0",
"typescript": "^5.3.0"
"prisma": "^7.3.0",
"typescript": "^5.9.3"
},
"resolutions": {
"hono": "^4.11.7",
"lodash": "^4.17.23"
},
"module": "src/index.ts"
}
2 changes: 1 addition & 1 deletion backend/src/api/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { prisma } from "../../db/prisma";

export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql"
provider: "postgresql",
}),

user: {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/api/auth/requireAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Elysia } from "elysia";
import { auth } from "./index";
import type { Elysia } from "elysia";
import { logger } from "../../logger/";
import { auth } from "./index";

interface User {
id: string;
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/auth/routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Elysia } from "elysia";
import { auth } from "./index";

export const authRoutes = new Elysia()
.mount(auth.handler)
export const authRoutes = new Elysia().mount(auth.handler);
Loading