better-ts-stack 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/LICENSE +21 -21
  2. package/dist/args.js +9 -0
  3. package/dist/builder/configGenerator.js +3 -1
  4. package/dist/builder/moduleSelector.js +8 -1
  5. package/dist/builder/readmeGenerator.js +12 -0
  6. package/dist/builder/templateContext.js +24 -0
  7. package/dist/output/nextSteps.js +4 -0
  8. package/dist/prompts/index.js +3 -1
  9. package/dist/prompts/stack.js +9 -0
  10. package/dist/types/index.js +3 -0
  11. package/dist/ui/messages.js +3 -0
  12. package/package.json +71 -71
  13. package/templates/backend/express/.prettierignore +52 -52
  14. package/templates/backend/express/.prettierrc +16 -16
  15. package/templates/backend/express/config.json +8 -8
  16. package/templates/backend/express/gitignore +6 -1
  17. package/templates/backend/express/tsconfig.eslint.json +9 -9
  18. package/templates/backend/nestjs/.prettierignore +52 -52
  19. package/templates/backend/nestjs/config.json +10 -10
  20. package/templates/backend/nestjs/gitignore +6 -1
  21. package/templates/backend/nestjs/src/app.module.ts.hbs +1 -1
  22. package/templates/backend/nestjs/src/health/{health.controller.ts → health.controller.ts.hbs} +8 -0
  23. package/templates/backend/nestjs/tsconfig.eslint.json +9 -9
  24. package/templates/frontend/nextjs/app/globals.css +89 -89
  25. package/templates/frontend/nextjs/app/layout.tsx +34 -34
  26. package/templates/frontend/nextjs/components/ui/button.tsx +51 -51
  27. package/templates/frontend/nextjs/components/ui/card.tsx +60 -60
  28. package/templates/frontend/nextjs/components/ui/field.tsx +67 -67
  29. package/templates/frontend/nextjs/components/ui/input.tsx +18 -18
  30. package/templates/frontend/nextjs/config.json +35 -37
  31. package/templates/frontend/nextjs/eslint.config.mjs +11 -11
  32. package/templates/frontend/nextjs/gitignore +3 -0
  33. package/templates/frontend/nextjs/next.config.ts.hbs +12 -12
  34. package/templates/frontend/nextjs/postcss.config.mjs +7 -7
  35. package/templates/frontend/nextjs/public/file.svg +1 -1
  36. package/templates/frontend/nextjs/public/globe.svg +1 -1
  37. package/templates/frontend/nextjs/public/window.svg +1 -1
  38. package/templates/frontend/tanstack/components.json +18 -18
  39. package/templates/frontend/tanstack/config.json +15 -15
  40. package/templates/frontend/tanstack/eslint.config.mjs +23 -23
  41. package/templates/frontend/tanstack/gitignore +42 -39
  42. package/templates/frontend/tanstack/public/favicon.svg +7 -7
  43. package/templates/frontend/tanstack/src/components/ui/button.tsx +51 -51
  44. package/templates/frontend/tanstack/src/components/ui/card.tsx +60 -60
  45. package/templates/frontend/tanstack/src/components/ui/field.tsx +67 -67
  46. package/templates/frontend/tanstack/src/components/ui/input.tsx +18 -18
  47. package/templates/frontend/tanstack/src/lib/utils.ts +6 -6
  48. package/templates/frontend/tanstack/src/router.tsx +31 -31
  49. package/templates/frontend/tanstack/src/routes/__root.tsx +69 -69
  50. package/templates/frontend/tanstack/tsconfig.json +22 -22
  51. package/templates/frontend/tanstack/vite.config.ts +5 -4
  52. package/templates/modules/agents/AGENTS.md.hbs +237 -0
  53. package/templates/modules/agents/CLAUDE.md +1 -0
  54. package/templates/modules/agents/config.json +10 -0
  55. package/templates/modules/auth/express/config.json +1 -1
  56. package/templates/modules/auth/express/src/lib/jwt.ts.hbs +27 -27
  57. package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +1 -2
  58. package/templates/modules/auth/nestjs/config.json +1 -1
  59. package/templates/modules/auth/nextjs/app/api/auth/[...all]/route.ts +4 -4
  60. package/templates/modules/auth/nextjs/config.json +18 -18
  61. package/templates/modules/auth/nextjs/lib/auth-client.ts +3 -3
  62. package/templates/{frontend/nextjs/proxy.ts.hbs → modules/auth/nextjs/proxy.ts} +1 -8
  63. package/templates/modules/auth/tanstack/config.json +18 -18
  64. package/templates/modules/auth/tanstack/src/lib/auth-client.ts +2 -2
  65. package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +8 -8
  66. package/templates/modules/auth/tanstack/src/lib/auth.ts.hbs +37 -37
  67. package/templates/modules/auth/tanstack/src/routes/api/auth/$.ts +15 -15
  68. package/templates/modules/auth/tanstack/src/routes/dashboard.tsx +110 -110
  69. package/templates/modules/auth/tanstack/src/routes/sign-in.tsx +36 -36
  70. package/templates/modules/auth/tanstack/src/routes/sign-up.tsx +36 -36
  71. package/templates/modules/ci/.github/workflows/ci.yml.hbs +43 -0
  72. package/templates/modules/ci/config.json +10 -0
  73. package/templates/modules/docker/.dockerignore +3 -0
  74. package/templates/modules/docker/config.json +15 -15
  75. package/templates/modules/docker/docker-compose.yml.hbs +1 -1
  76. package/templates/modules/drizzle/express/config.json +26 -26
  77. package/templates/modules/drizzle/nestjs/config.json +26 -26
  78. package/templates/modules/drizzle/nextjs/config.json +26 -26
  79. package/templates/modules/drizzle/nextjs/drizzle.config.ts +13 -13
  80. package/templates/modules/drizzle/tanstack/config.json +26 -26
  81. package/templates/modules/drizzle/tanstack/drizzle.config.ts +12 -12
  82. package/templates/modules/drizzle/tanstack/src/lib/db.ts +13 -13
  83. package/templates/modules/mongoose/express/config.json +15 -15
  84. package/templates/modules/mongoose/express/src/lib/db.ts +43 -43
  85. package/templates/modules/mongoose/express/src/models/User.ts +48 -48
  86. package/templates/modules/mongoose/nestjs/config.json +15 -15
  87. package/templates/modules/mongoose/nextjs/config.json +15 -15
  88. package/templates/modules/mongoose/nextjs/models/User.ts +48 -48
  89. package/templates/modules/mongoose/tanstack/config.json +16 -16
  90. package/templates/modules/mongoose/tanstack/src/models/User.ts +48 -48
  91. package/templates/modules/prisma/express/config.json +27 -27
  92. package/templates/modules/prisma/express/prisma/schema.prisma +23 -23
  93. package/templates/modules/prisma/express/prisma.config.ts +4 -2
  94. package/templates/modules/prisma/nestjs/config.json +27 -27
  95. package/templates/modules/prisma/nestjs/prisma.config.ts +4 -2
  96. package/templates/modules/prisma/nextjs/config.json +28 -28
  97. package/templates/modules/prisma/nextjs/lib/prisma.ts +18 -18
  98. package/templates/modules/prisma/nextjs/prisma.config.ts +14 -12
  99. package/templates/modules/prisma/tanstack/config.json +28 -28
  100. package/templates/modules/prisma/tanstack/prisma/schema.prisma.hbs +91 -91
  101. package/templates/modules/prisma/tanstack/prisma.config.ts +14 -12
  102. package/templates/modules/prisma/tanstack/src/lib/prisma.ts +17 -17
  103. package/templates/modules/rate-limit/express/config.json +1 -1
  104. package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +3 -1
  105. package/templates/modules/vscode/.vscode/extensions.json.hbs +29 -0
  106. package/templates/modules/vscode/.vscode/settings.json.hbs +22 -0
  107. package/templates/modules/vscode/config.json +10 -0
@@ -1,27 +1,27 @@
1
- {
2
- "id": "prisma",
3
- "name": "Prisma ORM",
4
- "description": "Prisma ORM with PostgreSQL database support",
5
- "type": "database",
6
- "dependencies": {
7
- "@prisma/adapter-pg": "^7.10.0",
8
- "@prisma/client": "^7.10.0"
9
- },
10
- "devDependencies": {
11
- "prisma": "^7.10.0"
12
- },
13
- "scripts": {
14
- "prisma:generate": "prisma generate",
15
- "prisma:migrate": "prisma migrate dev",
16
- "prisma:studio": "prisma studio",
17
- "pretype:check": "prisma generate",
18
- "prebuild": "prisma generate"
19
- },
20
- "envVars": {
21
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
22
- },
23
- "overrides": {
24
- "deepmerge-ts": "^8.0.2",
25
- "mysql2": "^3.24.3"
26
- }
27
- }
1
+ {
2
+ "id": "prisma",
3
+ "name": "Prisma ORM",
4
+ "description": "Prisma ORM with PostgreSQL database support",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "@prisma/adapter-pg": "^7.10.1",
8
+ "@prisma/client": "^7.10.1"
9
+ },
10
+ "devDependencies": {
11
+ "prisma": "^7.10.1"
12
+ },
13
+ "scripts": {
14
+ "prisma:generate": "prisma generate",
15
+ "prisma:migrate": "prisma migrate dev",
16
+ "prisma:studio": "prisma studio",
17
+ "pretype:check": "prisma generate",
18
+ "prebuild": "prisma generate"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
22
+ },
23
+ "overrides": {
24
+ "deepmerge-ts": "^8.0.2",
25
+ "mysql2": "^3.24.6"
26
+ }
27
+ }
@@ -1,24 +1,24 @@
1
- // Prisma schema file
2
- // Learn more: https://pris.ly/d/prisma-schema
3
-
4
- generator client {
1
+ // Prisma schema file
2
+ // Learn more: https://pris.ly/d/prisma-schema
3
+
4
+ generator client {
5
5
  provider = "prisma-client"
6
- moduleFormat = "cjs"
7
- output = "../src/generated/prisma"
8
- }
9
-
10
- datasource db {
11
- provider = "postgresql"
12
- }
13
-
14
- // Sample User model
15
- model User {
16
- id String @id @default(uuid())
17
- email String @unique
18
- name String?
19
- password String
20
- createdAt DateTime @default(now())
21
- updatedAt DateTime @updatedAt
22
-
23
- @@map("users")
24
- }
6
+ moduleFormat = "cjs"
7
+ output = "../src/generated/prisma"
8
+ }
9
+
10
+ datasource db {
11
+ provider = "postgresql"
12
+ }
13
+
14
+ // Sample User model
15
+ model User {
16
+ id String @id @default(uuid())
17
+ email String @unique
18
+ name String?
19
+ password String
20
+ createdAt DateTime @default(now())
21
+ updatedAt DateTime @updatedAt
22
+
23
+ @@map("users")
24
+ }
@@ -1,5 +1,5 @@
1
1
  import "dotenv/config";
2
- import { defineConfig, env } from "prisma/config";
2
+ import { defineConfig } from "prisma/config";
3
3
 
4
4
  export default defineConfig({
5
5
  schema: "prisma/schema.prisma",
@@ -7,6 +7,8 @@ export default defineConfig({
7
7
  path: "prisma/migrations",
8
8
  },
9
9
  datasource: {
10
- url: env("DATABASE_URL"),
10
+ // prisma generate needs no URL, so a build without .env (CI, a host) works.
11
+ // Commands that connect report the empty URL
12
+ url: process.env.DATABASE_URL ?? "",
11
13
  },
12
14
  });
@@ -1,27 +1,27 @@
1
- {
2
- "id": "prisma",
3
- "name": "Prisma ORM",
4
- "description": "Prisma ORM for NestJS with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "@prisma/adapter-pg": "^7.10.0",
8
- "@prisma/client": "^7.10.0"
9
- },
10
- "devDependencies": {
11
- "prisma": "^7.10.0"
12
- },
13
- "scripts": {
14
- "prisma:generate": "prisma generate",
15
- "prisma:migrate": "prisma migrate dev",
16
- "prisma:studio": "prisma studio",
17
- "pretype:check": "prisma generate",
18
- "prebuild": "prisma generate"
19
- },
20
- "envVars": {
21
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
22
- },
23
- "overrides": {
24
- "deepmerge-ts": "^8.0.2",
25
- "mysql2": "^3.24.3"
26
- }
27
- }
1
+ {
2
+ "id": "prisma",
3
+ "name": "Prisma ORM",
4
+ "description": "Prisma ORM for NestJS with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "@prisma/adapter-pg": "^7.10.1",
8
+ "@prisma/client": "^7.10.1"
9
+ },
10
+ "devDependencies": {
11
+ "prisma": "^7.10.1"
12
+ },
13
+ "scripts": {
14
+ "prisma:generate": "prisma generate",
15
+ "prisma:migrate": "prisma migrate dev",
16
+ "prisma:studio": "prisma studio",
17
+ "pretype:check": "prisma generate",
18
+ "prebuild": "prisma generate"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
22
+ },
23
+ "overrides": {
24
+ "deepmerge-ts": "^8.0.2",
25
+ "mysql2": "^3.24.6"
26
+ }
27
+ }
@@ -1,5 +1,5 @@
1
1
  import "dotenv/config";
2
- import { defineConfig, env } from "prisma/config";
2
+ import { defineConfig } from "prisma/config";
3
3
 
4
4
  export default defineConfig({
5
5
  schema: "prisma/schema.prisma",
@@ -7,6 +7,8 @@ export default defineConfig({
7
7
  path: "prisma/migrations",
8
8
  },
9
9
  datasource: {
10
- url: env("DATABASE_URL"),
10
+ // prisma generate needs no URL, so a build without .env (CI, a host) works.
11
+ // Commands that connect report the empty URL
12
+ url: process.env.DATABASE_URL ?? "",
11
13
  },
12
14
  });
@@ -1,28 +1,28 @@
1
- {
2
- "id": "prisma",
3
- "name": "Prisma ORM",
4
- "description": "Prisma ORM for Next.js with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "@prisma/client": "^7.10.0",
8
- "@prisma/adapter-pg": "^7.10.0"
9
- },
10
- "devDependencies": {
11
- "prisma": "^7.10.0",
12
- "dotenv": "^17.4.2"
13
- },
14
- "scripts": {
15
- "prisma:generate": "prisma generate",
16
- "prisma:migrate": "prisma migrate dev",
17
- "prisma:studio": "prisma studio",
18
- "pretype:check": "prisma generate",
19
- "prebuild": "prisma generate"
20
- },
21
- "envVars": {
22
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
23
- },
24
- "overrides": {
25
- "deepmerge-ts": "^8.0.2",
26
- "mysql2": "^3.24.3"
27
- }
28
- }
1
+ {
2
+ "id": "prisma",
3
+ "name": "Prisma ORM",
4
+ "description": "Prisma ORM for Next.js with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "@prisma/client": "^7.10.1",
8
+ "@prisma/adapter-pg": "^7.10.1"
9
+ },
10
+ "devDependencies": {
11
+ "prisma": "^7.10.1",
12
+ "dotenv": "^17.4.2"
13
+ },
14
+ "scripts": {
15
+ "prisma:generate": "prisma generate",
16
+ "prisma:migrate": "prisma migrate dev",
17
+ "prisma:studio": "prisma studio",
18
+ "pretype:check": "prisma generate",
19
+ "prebuild": "prisma generate"
20
+ },
21
+ "envVars": {
22
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
23
+ },
24
+ "overrides": {
25
+ "deepmerge-ts": "^8.0.2",
26
+ "mysql2": "^3.24.6"
27
+ }
28
+ }
@@ -1,18 +1,18 @@
1
- import { PrismaPg } from "@prisma/adapter-pg";
2
-
3
- import { PrismaClient } from "../generated/client";
4
-
5
- const globalForPrisma = global as unknown as {
6
- prisma: PrismaClient;
7
- };
8
- const adapter = new PrismaPg({
9
- connectionString: process.env.DATABASE_URL,
10
- });
11
- const prisma =
12
- globalForPrisma.prisma ||
13
- new PrismaClient({
14
- adapter,
15
- });
16
- if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
17
-
18
- export default prisma;
1
+ import { PrismaPg } from "@prisma/adapter-pg";
2
+
3
+ import { PrismaClient } from "../generated/client";
4
+
5
+ const globalForPrisma = global as unknown as {
6
+ prisma: PrismaClient;
7
+ };
8
+ const adapter = new PrismaPg({
9
+ connectionString: process.env.DATABASE_URL,
10
+ });
11
+ const prisma =
12
+ globalForPrisma.prisma ||
13
+ new PrismaClient({
14
+ adapter,
15
+ });
16
+ if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
17
+
18
+ export default prisma;
@@ -1,12 +1,14 @@
1
- import "dotenv/config";
2
- import { defineConfig, env } from "prisma/config";
3
-
4
- export default defineConfig({
5
- schema: "prisma/schema.prisma",
6
- migrations: {
7
- path: "prisma/migrations",
8
- },
9
- datasource: {
10
- url: env("DATABASE_URL"),
11
- },
12
- });
1
+ import "dotenv/config";
2
+ import { defineConfig } from "prisma/config";
3
+
4
+ export default defineConfig({
5
+ schema: "prisma/schema.prisma",
6
+ migrations: {
7
+ path: "prisma/migrations",
8
+ },
9
+ datasource: {
10
+ // prisma generate needs no URL, so a build without .env (CI, a host) works.
11
+ // Commands that connect report the empty URL
12
+ url: process.env.DATABASE_URL ?? "",
13
+ },
14
+ });
@@ -1,28 +1,28 @@
1
- {
2
- "id": "prisma",
3
- "name": "Prisma ORM",
4
- "description": "Prisma ORM for TanStack Start with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "@prisma/client": "^7.10.0",
8
- "@prisma/adapter-pg": "^7.10.0"
9
- },
10
- "devDependencies": {
11
- "prisma": "^7.10.0",
12
- "dotenv": "^17.4.2"
13
- },
14
- "scripts": {
15
- "prisma:generate": "prisma generate",
16
- "prisma:migrate": "prisma migrate dev",
17
- "prisma:studio": "prisma studio",
18
- "pretype:check": "prisma generate",
19
- "prebuild": "prisma generate"
20
- },
21
- "envVars": {
22
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
23
- },
24
- "overrides": {
25
- "deepmerge-ts": "^8.0.2",
26
- "mysql2": "^3.24.3"
27
- }
28
- }
1
+ {
2
+ "id": "prisma",
3
+ "name": "Prisma ORM",
4
+ "description": "Prisma ORM for TanStack Start with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "@prisma/client": "^7.10.1",
8
+ "@prisma/adapter-pg": "^7.10.1"
9
+ },
10
+ "devDependencies": {
11
+ "prisma": "^7.10.1",
12
+ "dotenv": "^17.4.2"
13
+ },
14
+ "scripts": {
15
+ "prisma:generate": "prisma generate",
16
+ "prisma:migrate": "prisma migrate dev",
17
+ "prisma:studio": "prisma studio",
18
+ "pretype:check": "prisma generate",
19
+ "prebuild": "prisma generate"
20
+ },
21
+ "envVars": {
22
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
23
+ },
24
+ "overrides": {
25
+ "deepmerge-ts": "^8.0.2",
26
+ "mysql2": "^3.24.6"
27
+ }
28
+ }
@@ -1,91 +1,91 @@
1
- // Prisma schema file
2
- // Learn more: https://pris.ly/d/prisma-schema
3
-
4
- generator client {
5
- provider = "prisma-client"
6
- output = "../generated"
7
- }
8
-
9
- datasource db {
10
- provider = "postgresql"
11
- }
12
-
13
- {{#if useAuth}}
14
-
15
- model User {
16
- id String @id
17
- name String
18
- email String
19
- emailVerified Boolean @default(false)
20
- image String?
21
- createdAt DateTime @default(now())
22
- updatedAt DateTime @updatedAt
23
- sessions Session[]
24
- accounts Account[]
25
-
26
- @@unique([email])
27
- @@map("user")
28
- }
29
-
30
- model Session {
31
- id String @id
32
- expiresAt DateTime
33
- token String
34
- createdAt DateTime @default(now())
35
- updatedAt DateTime @updatedAt
36
- ipAddress String?
37
- userAgent String?
38
- userId String
39
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
40
-
41
- @@unique([token])
42
- @@index([userId])
43
- @@map("session")
44
- }
45
-
46
- model Account {
47
- id String @id
48
- accountId String
49
- providerId String
50
- userId String
51
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
52
- accessToken String?
53
- refreshToken String?
54
- idToken String?
55
- accessTokenExpiresAt DateTime?
56
- refreshTokenExpiresAt DateTime?
57
- scope String?
58
- password String?
59
- createdAt DateTime @default(now())
60
- updatedAt DateTime @updatedAt
61
-
62
- @@index([userId])
63
- @@unique([providerId, accountId])
64
- @@map("account")
65
- }
66
-
67
- model Verification {
68
- id String @id
69
- identifier String
70
- value String
71
- expiresAt DateTime
72
- createdAt DateTime @default(now())
73
- updatedAt DateTime @updatedAt
74
-
75
- @@index([identifier])
76
- @@map("verification")
77
- }
78
-
79
- {{else}}
80
- // Sample User model
81
- model User {
82
- id String @id @default(uuid())
83
- email String @unique
84
- name String?
85
- password String
86
- createdAt DateTime @default(now())
87
- updatedAt DateTime @updatedAt
88
-
89
- @@map("users")
90
- }
91
- {{/if}}
1
+ // Prisma schema file
2
+ // Learn more: https://pris.ly/d/prisma-schema
3
+
4
+ generator client {
5
+ provider = "prisma-client"
6
+ output = "../generated"
7
+ }
8
+
9
+ datasource db {
10
+ provider = "postgresql"
11
+ }
12
+
13
+ {{#if useAuth}}
14
+
15
+ model User {
16
+ id String @id
17
+ name String
18
+ email String
19
+ emailVerified Boolean @default(false)
20
+ image String?
21
+ createdAt DateTime @default(now())
22
+ updatedAt DateTime @updatedAt
23
+ sessions Session[]
24
+ accounts Account[]
25
+
26
+ @@unique([email])
27
+ @@map("user")
28
+ }
29
+
30
+ model Session {
31
+ id String @id
32
+ expiresAt DateTime
33
+ token String
34
+ createdAt DateTime @default(now())
35
+ updatedAt DateTime @updatedAt
36
+ ipAddress String?
37
+ userAgent String?
38
+ userId String
39
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
40
+
41
+ @@unique([token])
42
+ @@index([userId])
43
+ @@map("session")
44
+ }
45
+
46
+ model Account {
47
+ id String @id
48
+ accountId String
49
+ providerId String
50
+ userId String
51
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
52
+ accessToken String?
53
+ refreshToken String?
54
+ idToken String?
55
+ accessTokenExpiresAt DateTime?
56
+ refreshTokenExpiresAt DateTime?
57
+ scope String?
58
+ password String?
59
+ createdAt DateTime @default(now())
60
+ updatedAt DateTime @updatedAt
61
+
62
+ @@index([userId])
63
+ @@unique([providerId, accountId])
64
+ @@map("account")
65
+ }
66
+
67
+ model Verification {
68
+ id String @id
69
+ identifier String
70
+ value String
71
+ expiresAt DateTime
72
+ createdAt DateTime @default(now())
73
+ updatedAt DateTime @updatedAt
74
+
75
+ @@index([identifier])
76
+ @@map("verification")
77
+ }
78
+
79
+ {{else}}
80
+ // Sample User model
81
+ model User {
82
+ id String @id @default(uuid())
83
+ email String @unique
84
+ name String?
85
+ password String
86
+ createdAt DateTime @default(now())
87
+ updatedAt DateTime @updatedAt
88
+
89
+ @@map("users")
90
+ }
91
+ {{/if}}
@@ -1,12 +1,14 @@
1
- import "dotenv/config";
2
- import { defineConfig, env } from "prisma/config";
3
-
4
- export default defineConfig({
5
- schema: "prisma/schema.prisma",
6
- migrations: {
7
- path: "prisma/migrations",
8
- },
9
- datasource: {
10
- url: env("DATABASE_URL"),
11
- },
12
- });
1
+ import "dotenv/config";
2
+ import { defineConfig } from "prisma/config";
3
+
4
+ export default defineConfig({
5
+ schema: "prisma/schema.prisma",
6
+ migrations: {
7
+ path: "prisma/migrations",
8
+ },
9
+ datasource: {
10
+ // prisma generate needs no URL, so a build without .env (CI, a host) works.
11
+ // Commands that connect report the empty URL
12
+ url: process.env.DATABASE_URL ?? "",
13
+ },
14
+ });
@@ -1,18 +1,18 @@
1
- import { PrismaPg } from "@prisma/adapter-pg";
2
-
3
- import { PrismaClient } from "../../generated/client";
4
-
5
- const globalForPrisma = global as unknown as {
6
- prisma: PrismaClient;
7
- };
8
- const adapter = new PrismaPg({
9
- connectionString: process.env.DATABASE_URL,
10
- });
11
- const prisma =
12
- globalForPrisma.prisma ||
13
- new PrismaClient({
14
- adapter,
15
- });
16
- if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
17
-
1
+ import { PrismaPg } from "@prisma/adapter-pg";
2
+
3
+ import { PrismaClient } from "../../generated/client";
4
+
5
+ const globalForPrisma = global as unknown as {
6
+ prisma: PrismaClient;
7
+ };
8
+ const adapter = new PrismaPg({
9
+ connectionString: process.env.DATABASE_URL,
10
+ });
11
+ const prisma =
12
+ globalForPrisma.prisma ||
13
+ new PrismaClient({
14
+ adapter,
15
+ });
16
+ if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
17
+
18
18
  export default prisma;
@@ -4,7 +4,7 @@
4
4
  "description": "Per-IP request limits for Express with express-rate-limit",
5
5
  "type": "feature",
6
6
  "dependencies": {
7
- "express-rate-limit": "^8.7.1"
7
+ "express-rate-limit": "^8.7.2"
8
8
  },
9
9
  "devDependencies": {},
10
10
  "scripts": {},
@@ -4,12 +4,14 @@ import { rateLimit } from "express-rate-limit";
4
4
  // balancer, set app.set("trust proxy", 1) so the real client IP is used.
5
5
  const FIFTEEN_MINUTES = 15 * 60 * 1000;
6
6
 
7
- // Every route: 100 requests per IP in 15 minutes
7
+ // Every route: 100 requests per IP in 15 minutes. The health check is left out
8
+ // because Docker and load balancers call it on a schedule
8
9
  export const apiLimiter = rateLimit({
9
10
  windowMs: FIFTEEN_MINUTES,
10
11
  limit: 100,
11
12
  standardHeaders: "draft-8",
12
13
  legacyHeaders: false,
14
+ skip: (req) => req.path === "/health",
13
15
  });
14
16
 
15
17
  // Sign-up and login: 10 attempts per IP in 15 minutes, against password guessing