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

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci --ignore-scripts
- run: npx prisma generate
env:
DIRECT_URL: "postgresql://placeholder"
- run: npx tsc --noEmit

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci --ignore-scripts
- run: npm run lint

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci --ignore-scripts
- run: npm run format:check
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ Internal authentication service
cp .env.example .env
```

| Variable | Purpose |
| --- | --- |
| `DATABASE_URL` | Pooled Postgres connection used by the application (via PgBouncer in prod) |
| `DIRECT_URL` | Direct Postgres connection used by Prisma for migrations |
| `NEXT_PUBLIC_SUPABASE_URL` | Supabase project URL (public) |
| `NEXT_PUBLIC_SUPABASE_ANON_KEY` | Supabase anon key — "Publishable" in CLI output (public) |
| `SUPABASE_SERVICE_ROLE_KEY` | Supabase service role key — "Secret" in CLI output (**never expose to the client**) |
| Variable | Purpose |
| ------------------------------- | ----------------------------------------------------------------------------------- |
| `DATABASE_URL` | Pooled Postgres connection used by the application (via PgBouncer in prod) |
| `DIRECT_URL` | Direct Postgres connection used by Prisma for migrations |
| `NEXT_PUBLIC_SUPABASE_URL` | Supabase project URL (public) |
| `NEXT_PUBLIC_SUPABASE_ANON_KEY` | Supabase anon key — "Publishable" in CLI output (public) |
| `SUPABASE_SERVICE_ROLE_KEY` | Supabase service role key — "Secret" in CLI output (**never expose to the client**) |

> Locally there is no connection pooling, so `DATABASE_URL` and `DIRECT_URL` will be the same.

Expand All @@ -63,11 +63,11 @@ Internal authentication service

## Scripts

| Command | Description |
| --- | --- |
| `npm run dev` | Start Next.js dev server |
| `npm run build` | Production build |
| `npm run start` | Start production server |
| `npm run lint` | Run ESLint |
| `npm run format` | Format code with Prettier |
| Command | Description |
| ---------------------- | -------------------------------- |
| `npm run dev` | Start Next.js dev server |
| `npm run build` | Production build |
| `npm run start` | Start production server |
| `npm run lint` | Run ESLint |
| `npm run format` | Format code with Prettier |
| `npm run format:check` | Check formatting without writing |
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const eslintConfig = defineConfig([
"out/**",
"build/**",
"next-env.d.ts",
// Generated files:
"src/generated/**",
]),
]);

Expand Down
127 changes: 62 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/pg": "^8.20.0",
"@types/pg": "^8.11.11",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
Expand Down
2 changes: 1 addition & 1 deletion prisma.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
seed: 'npx ts-node prisma/seed.ts',
seed: "npx ts-node prisma/seed.ts",
},
datasource: {
url: env("DIRECT_URL"),
Expand Down
42 changes: 21 additions & 21 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import 'dotenv/config'
import pg from 'pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '../src/generated/prisma/index.js'
import "dotenv/config";
import pg from "pg";
import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "../src/generated/prisma/index.js";

// Connect to whatever database is specified by DATABASE_URL
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });

const adapter = new PrismaPg(pool as any)
const adapter = new PrismaPg(pool);

const prisma = new PrismaClient({ adapter })
const prisma = new PrismaClient({ adapter });

async function main() {
// Fake Supabase user IDs
const adminSupabaseId = '00000000-0000-0000-0000-000000000001'
const userSupabaseId = '00000000-0000-0000-0000-000000000002'
const adminSupabaseId = "00000000-0000-0000-0000-000000000001";
const userSupabaseId = "00000000-0000-0000-0000-000000000002";

const admin = await prisma.user.upsert({
where: { supabaseUserId: adminSupabaseId },
update: {},
create: { supabaseUserId: adminSupabaseId, isAdmin: true },
})
});

const user = await prisma.user.upsert({
where: { supabaseUserId: userSupabaseId },
update: {},
create: { supabaseUserId: userSupabaseId, isAdmin: false },
})
});

const project1 = await prisma.project.create({
data: { name: 'Attendance Manager', description: 'Cool project' },
})
data: { name: "Attendance Manager", description: "Cool project" },
});

const project2 = await prisma.project.create({
data: { name: 'Website Creation', description: 'Less project' },
})
data: { name: "Website Creation", description: "Less project" },
});

await prisma.userProject.createMany({
data: [
Expand All @@ -42,22 +42,22 @@ async function main() {
{ userId: user.id, projectId: project1.id },
],
skipDuplicates: true,
})
});

await prisma.session.create({
data: {
userId: admin.id,
projectId: project1.id,
token: 'admin-session-token',
token: "admin-session-token",
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24), // 24h
},
})
});

console.log('data seeded!')
console.log("data seeded!");
}

main()
.catch(console.error)
.finally(async () => {
await prisma.$disconnect()
})
await prisma.$disconnect();
});
Loading
Loading