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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
verify:
runs-on: ubuntu-latest

env:
DIRECT_URL: postgresql://ci:ci@localhost:5432/ci
DATABASE_URL: postgresql://ci:ci@localhost:5432/ci

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -23,10 +27,6 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Prisma generate (backend)
run: npx prisma generate
working-directory: ./apps/backend

- name: Lint
run: npm run lint

Expand Down
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"endOfLine": "auto"
}
1 change: 1 addition & 0 deletions apps/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CORS_ALLOWED_ORIGINS=http://localhost:5173,https://bodmat.github.io

# Database
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/CoinRadar?schema=public
DIRECT_URL=postgresql://postgres:postgres@localhost:5432/CoinRadar?schema=public

# JWT
# Use long random strings in real environments
Expand Down
9 changes: 4 additions & 5 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"tsx": "^4.20.6"
},
"dependencies": {
"@prisma/client": "6.19.0",
"@prisma/adapter-pg": "^7.8.0",
"@prisma/client": "^7.8.0",
"@types/bcrypt": "^6.0.0",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.5",
Expand All @@ -36,11 +37,9 @@
"cors": "^2.8.5",
"express": "^5.1.0",
"jsonwebtoken": "^9.0.2",
"prisma": "6.19.0",
"pg": "^8.21.0",
"prisma": "^7.8.0",
"typescript": "^5.9.3",
"zod": "^4.1.13"
},
"prisma": {
"seed": "tsx ./prisma/seed.ts"
}
}
13 changes: 13 additions & 0 deletions apps/backend/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
seed: "tsx prisma/seed.ts",
},
datasource: {
url: env("DIRECT_URL"),
},
});
1 change: 0 additions & 1 deletion apps/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

enum BuyOrSell {
Expand Down
7 changes: 6 additions & 1 deletion apps/backend/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { PrismaClient, BuyOrSell } from "@prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";
import { randomUUID } from "node:crypto";
import bcrypt from "bcrypt";

const prisma = new PrismaClient();
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});

const prisma = new PrismaClient({ adapter });

const NOW = new Date("2026-05-20T12:00:00.000Z");
const PIVOT_DATE = new Date("2026-03-01T00:00:00.000Z");
Expand Down
7 changes: 6 additions & 1 deletion apps/backend/src/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { PrismaClient } from "@prisma/client";
import { PrismaPg } from "@prisma/adapter-pg";

const prisma = new PrismaClient();
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});

const prisma = new PrismaClient({ adapter });

export default prisma;
4 changes: 3 additions & 1 deletion apps/backend/tests/setup/globalSetup.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ module.exports = async () => {
const backendRoot = path.resolve(__dirname, '../..');

process.env.DATABASE_URL = databaseUrl;
process.env.DIRECT_URL = databaseUrl;
process.env.JWT_SECRET = process.env.JWT_SECRET || 'test-access-secret';
process.env.JWT_REFRESH_SECRET = process.env.JWT_REFRESH_SECRET || 'test-refresh-secret';
process.env.FRONTEND_URL = process.env.FRONTEND_URL || 'http://localhost:5173';
process.env.CORS_ALLOWED_ORIGINS = process.env.CORS_ALLOWED_ORIGINS || 'http://localhost:5173';
process.env.COOKIE_SAME_SITE = process.env.COOKIE_SAME_SITE || 'lax';
process.env.NODE_ENV = 'test';

execSync('npx prisma db push --skip-generate --schema=./prisma/schema.prisma', {
execSync('npx prisma db push --schema=./prisma/schema.prisma', {
cwd: backendRoot,
env: {
...process.env,
DATABASE_URL: databaseUrl,
DIRECT_URL: databaseUrl,
},
stdio: 'inherit',
});
Expand Down
Loading
Loading