Skip to content

Commit ace3f8f

Browse files
authored
Merge pull request #9 from SGAOperations/auth-21
2 parents 8363c57 + 7286f02 commit ace3f8f

File tree

18 files changed

+326
-279
lines changed

18 files changed

+326
-279
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
jobs:
14+
typecheck:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
cache: npm
22+
- run: npm ci --ignore-scripts
23+
- run: npx prisma generate
24+
env:
25+
DIRECT_URL: "postgresql://placeholder"
26+
- run: npx tsc --noEmit
27+
28+
lint:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 22
35+
cache: npm
36+
- run: npm ci --ignore-scripts
37+
- run: npm run lint
38+
39+
format:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: 22
46+
cache: npm
47+
- run: npm ci --ignore-scripts
48+
- run: npm run format:check

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ Internal authentication service
3939
cp .env.example .env
4040
```
4141

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

5050
> Locally there is no connection pooling, so `DATABASE_URL` and `DIRECT_URL` will be the same.
5151
@@ -63,11 +63,11 @@ Internal authentication service
6363

6464
## Scripts
6565

66-
| Command | Description |
67-
| --- | --- |
68-
| `npm run dev` | Start Next.js dev server |
69-
| `npm run build` | Production build |
70-
| `npm run start` | Start production server |
71-
| `npm run lint` | Run ESLint |
72-
| `npm run format` | Format code with Prettier |
66+
| Command | Description |
67+
| ---------------------- | -------------------------------- |
68+
| `npm run dev` | Start Next.js dev server |
69+
| `npm run build` | Production build |
70+
| `npm run start` | Start production server |
71+
| `npm run lint` | Run ESLint |
72+
| `npm run format` | Format code with Prettier |
7373
| `npm run format:check` | Check formatting without writing |

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const eslintConfig = defineConfig([
1414
"out/**",
1515
"build/**",
1616
"next-env.d.ts",
17+
// Generated files:
18+
"src/generated/**",
1719
]),
1820
]);
1921

package-lock.json

Lines changed: 62 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"devDependencies": {
4242
"@tailwindcss/postcss": "^4",
4343
"@types/node": "^20",
44-
"@types/pg": "^8.20.0",
44+
"@types/pg": "^8.11.11",
4545
"@types/react": "^19",
4646
"@types/react-dom": "^19",
4747
"eslint": "^9",

prisma.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineConfig({
77
schema: "prisma/schema.prisma",
88
migrations: {
99
path: "prisma/migrations",
10-
seed: 'npx ts-node prisma/seed.ts',
10+
seed: "npx ts-node prisma/seed.ts",
1111
},
1212
datasource: {
1313
url: env("DIRECT_URL"),

prisma/seed.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
import 'dotenv/config'
2-
import pg from 'pg'
3-
import { PrismaPg } from '@prisma/adapter-pg'
4-
import { PrismaClient } from '../src/generated/prisma/index.js'
1+
import "dotenv/config";
2+
import pg from "pg";
3+
import { PrismaPg } from "@prisma/adapter-pg";
4+
import { PrismaClient } from "../src/generated/prisma/index.js";
55

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

9-
const adapter = new PrismaPg(pool as any)
9+
const adapter = new PrismaPg(pool);
1010

11-
const prisma = new PrismaClient({ adapter })
11+
const prisma = new PrismaClient({ adapter });
1212

1313
async function main() {
1414
// Fake Supabase user IDs
15-
const adminSupabaseId = '00000000-0000-0000-0000-000000000001'
16-
const userSupabaseId = '00000000-0000-0000-0000-000000000002'
15+
const adminSupabaseId = "00000000-0000-0000-0000-000000000001";
16+
const userSupabaseId = "00000000-0000-0000-0000-000000000002";
1717

1818
const admin = await prisma.user.upsert({
1919
where: { supabaseUserId: adminSupabaseId },
2020
update: {},
2121
create: { supabaseUserId: adminSupabaseId, isAdmin: true },
22-
})
22+
});
2323

2424
const user = await prisma.user.upsert({
2525
where: { supabaseUserId: userSupabaseId },
2626
update: {},
2727
create: { supabaseUserId: userSupabaseId, isAdmin: false },
28-
})
28+
});
2929

3030
const project1 = await prisma.project.create({
31-
data: { name: 'Attendance Manager', description: 'Cool project' },
32-
})
31+
data: { name: "Attendance Manager", description: "Cool project" },
32+
});
3333

3434
const project2 = await prisma.project.create({
35-
data: { name: 'Website Creation', description: 'Less project' },
36-
})
35+
data: { name: "Website Creation", description: "Less project" },
36+
});
3737

3838
await prisma.userProject.createMany({
3939
data: [
@@ -42,22 +42,22 @@ async function main() {
4242
{ userId: user.id, projectId: project1.id },
4343
],
4444
skipDuplicates: true,
45-
})
45+
});
4646

4747
await prisma.session.create({
4848
data: {
4949
userId: admin.id,
5050
projectId: project1.id,
51-
token: 'admin-session-token',
51+
token: "admin-session-token",
5252
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24), // 24h
5353
},
54-
})
54+
});
5555

56-
console.log('data seeded!')
56+
console.log("data seeded!");
5757
}
5858

5959
main()
6060
.catch(console.error)
6161
.finally(async () => {
62-
await prisma.$disconnect()
63-
})
62+
await prisma.$disconnect();
63+
});

0 commit comments

Comments
 (0)