Skip to content

Commit 5a8bead

Browse files
committed
feat: add api_v2 — Hono+Prisma rewrite of Python FastAPI backend
- Port all ~110 endpoints from Python to TypeScript using Hono, Zod, Prisma - 28 Prisma models with UUIDs, soft delete, proper indexing - JWT auth (required + optional), admin middleware, error handler - BullMQ queues for notifications and broadcasts - All routes flattened (no nested resources except actions) - Modules: auth, account, sessions, users, posts, channels, channel-members, media, reactions, articles, courses (4 sub-modules), extras, invite-codes, notifications, notification-preferences, broadcasts, resources, applinks, settings, presence - Vitest integration test suite with 21 test files, ~150+ test cases - Test helpers: createTestUser, createTestAdmin, getAuthHeaders, cleanupAll - Flat route structure per user preference
1 parent 2965089 commit 5a8bead

104 files changed

Lines changed: 15097 additions & 86 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/api_v2/.env.test‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
DATABASE_URL="postgresql://opencircle:opencircle@localhost:5432/opencircle_v2_test"
2+
SECRET_KEY="test-secret-key-for-vitest"
3+
REFRESH_TOKEN_SECRET_KEY="test-refresh-secret-key-for-vitest"
4+
ACCESS_TOKEN_EXPIRE_MINUTES=15
5+
REFRESH_TOKEN_EXPIRE_DAYS=30
6+
R2_ENDPOINT_URL=""
7+
R2_ACCESS_KEY_ID=""
8+
R2_SECRET_ACCESS_KEY=""
9+
R2_BUCKET_NAME=""
10+
R2_PUBLIC_URL=""
11+
REDIS_URL="redis://localhost:6379"
12+
GITHUB_CLIENT_ID=""
13+
GITHUB_CLIENT_SECRET=""
14+
GOOGLE_CLIENT_ID=""
15+
GOOGLE_CLIENT_SECRET=""
16+
RESEND_API_KEY=""
17+
PLATFORM_URL="http://localhost:3000"
18+
ADMIN_URL="http://localhost:3001"

‎apps/api_v2/.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
dist/
3+
.env
4+
*.log
5+
src/generated/prisma/
6+
package-lock.json

‎apps/api_v2/moon.yml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
id: api-v2
2+
language: typescript
3+
4+
tasks:
5+
format:
6+
command: "pnpm exec biome format --write src/"
7+
options:
8+
runInCI: false
9+
10+
lint:
11+
command: "pnpm exec biome check src/"
12+
13+
lint-fix:
14+
command: "pnpm exec biome check --write --unsafe src/"
15+
options:
16+
runInCI: false
17+
18+
typecheck:
19+
command: "pnpm typecheck"
20+
21+
sync:
22+
command: "pnpm install"
23+
options:
24+
runInCI: false
25+
26+
dev:
27+
command: "pnpm dev"
28+
options:
29+
runInCI: false
30+
31+
build:
32+
command: "pnpm build"
33+
34+
db-generate:
35+
command: "pnpm db:generate"
36+
options:
37+
runInCI: false
38+
39+
db-migrate:
40+
command: "pnpm db:migrate:dev"
41+
options:
42+
runInCI: false

‎apps/api_v2/package.json‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@opencircle/api-v2",
3+
"version": "0.0.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": {
7+
"dev": "tsx watch src/index.ts",
8+
"build": "tsc",
9+
"start": "node dist/index.js",
10+
"typecheck": "tsc --noEmit",
11+
"check": "biome check src/",
12+
"db:generate": "prisma generate",
13+
"db:migrate": "prisma migrate deploy",
14+
"db:migrate:dev": "prisma migrate dev",
15+
"db:seed": "tsx prisma/seed.ts",
16+
"db:studio": "prisma studio",
17+
"test": "vitest run",
18+
"test:watch": "vitest",
19+
"test:coverage": "vitest run --coverage"
20+
},
21+
"dependencies": {
22+
"@aws-sdk/client-s3": "^3.850.0",
23+
"@hono/node-server": "^1.14.4",
24+
"@hono/zod-validator": "^0.7.3",
25+
"@prisma/adapter-pg": "^6.14.0",
26+
"@prisma/client": "^6.14.0",
27+
"bcryptjs": "^2.4.3",
28+
"bullmq": "^5.57.0",
29+
"dotenv": "^17.2.1",
30+
"hono": "^4.9.4",
31+
"jsonwebtoken": "^9.0.2",
32+
"nanoid": "^5.1.5",
33+
"resend": "^6.0.2",
34+
"zod": "^3.25.76"
35+
},
36+
"devDependencies": {
37+
"@biomejs/biome": "^2.2.6",
38+
"@types/bcryptjs": "^2.4.6",
39+
"@types/jsonwebtoken": "^9.0.10",
40+
"@types/node": "^24.6.0",
41+
"@vitest/coverage-v8": "^3.2.4",
42+
"prisma": "^6.14.0",
43+
"tsx": "^4.20.5",
44+
"typescript": "~5.9.3",
45+
"vitest": "^3.2.4"
46+
}
47+
}

‎apps/api_v2/prisma.config.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { config } from "dotenv";
2+
import { defineConfig } from "prisma/config";
3+
4+
config({ path: "../../.env" });
5+
6+
export default defineConfig({
7+
schema: "prisma/schema.prisma",
8+
migrations: {
9+
path: "prisma/migrations",
10+
},
11+
datasource: {
12+
url: process.env.DATABASE_URL,
13+
},
14+
});

0 commit comments

Comments
 (0)