better-ts-stack 2.1.1 → 2.2.0

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 (174) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +16 -8
  3. package/dist/args.js +7 -0
  4. package/dist/builder/buildPlanner.js +7 -1
  5. package/dist/builder/configGenerator.js +28 -3
  6. package/dist/builder/index.js +2 -1
  7. package/dist/builder/moduleSelector.js +6 -1
  8. package/dist/builder/readmeGenerator.js +8 -2
  9. package/dist/builder/templateContext.js +1 -0
  10. package/dist/output/nextSteps.js +2 -4
  11. package/dist/prompts/stack.js +6 -1
  12. package/dist/types/index.js +2 -0
  13. package/dist/ui/messages.js +2 -0
  14. package/package.json +71 -71
  15. package/templates/backend/express/.prettierignore +52 -52
  16. package/templates/backend/express/.prettierrc +16 -16
  17. package/templates/backend/express/gitignore +3 -1
  18. package/templates/backend/express/src/env.ts.hbs +13 -2
  19. package/templates/backend/express/src/index.ts.hbs +31 -2
  20. package/templates/backend/express/tsconfig.eslint.json +9 -9
  21. package/templates/backend/nestjs/.prettierignore +52 -52
  22. package/templates/backend/nestjs/gitignore +3 -1
  23. package/templates/backend/nestjs/src/app.module.ts.hbs +4 -1
  24. package/templates/backend/nestjs/src/env.ts.hbs +13 -2
  25. package/templates/backend/nestjs/src/health/health.controller.ts.hbs +7 -0
  26. package/templates/backend/nestjs/src/{main.ts → main.ts.hbs} +11 -0
  27. package/templates/backend/nestjs/tsconfig.eslint.json +9 -9
  28. package/templates/frontend/nextjs/app/globals.css +129 -89
  29. package/templates/frontend/nextjs/app/layout.tsx +36 -34
  30. package/templates/frontend/nextjs/app/page.tsx.hbs +63 -43
  31. package/templates/frontend/nextjs/components/ui/alert.tsx +75 -0
  32. package/templates/frontend/nextjs/components/ui/badge.tsx +51 -0
  33. package/templates/frontend/nextjs/components/ui/button.tsx +57 -51
  34. package/templates/frontend/nextjs/components/ui/card.tsx +102 -60
  35. package/templates/frontend/nextjs/components/ui/field.tsx +238 -67
  36. package/templates/frontend/nextjs/components/ui/input.tsx +19 -18
  37. package/templates/frontend/nextjs/components/ui/label.tsx +19 -0
  38. package/templates/frontend/nextjs/components/ui/separator.tsx +24 -0
  39. package/templates/frontend/nextjs/components/ui/skeleton.tsx +13 -0
  40. package/templates/frontend/nextjs/components/ui/spinner.tsx +10 -0
  41. package/templates/frontend/nextjs/components.json +11 -5
  42. package/templates/frontend/nextjs/config.json +36 -35
  43. package/templates/frontend/nextjs/eslint.config.mjs +11 -11
  44. package/templates/frontend/nextjs/lib/utils.ts +1 -6
  45. package/templates/frontend/nextjs/next.config.ts.hbs +12 -12
  46. package/templates/frontend/nextjs/postcss.config.mjs +7 -7
  47. package/templates/frontend/nextjs/public/file.svg +1 -1
  48. package/templates/frontend/nextjs/public/globe.svg +1 -1
  49. package/templates/frontend/nextjs/public/window.svg +1 -1
  50. package/templates/frontend/tanstack/components.json +25 -18
  51. package/templates/frontend/tanstack/config.json +5 -2
  52. package/templates/frontend/tanstack/eslint.config.mjs +23 -23
  53. package/templates/frontend/tanstack/gitignore +39 -39
  54. package/templates/frontend/tanstack/public/favicon.svg +7 -7
  55. package/templates/frontend/tanstack/src/components/ui/alert.tsx +75 -0
  56. package/templates/frontend/tanstack/src/components/ui/badge.tsx +51 -0
  57. package/templates/frontend/tanstack/src/components/ui/button.tsx +57 -51
  58. package/templates/frontend/tanstack/src/components/ui/card.tsx +102 -60
  59. package/templates/frontend/tanstack/src/components/ui/field.tsx +236 -67
  60. package/templates/frontend/tanstack/src/components/ui/input.tsx +19 -18
  61. package/templates/frontend/tanstack/src/components/ui/label.tsx +17 -0
  62. package/templates/frontend/tanstack/src/components/ui/separator.tsx +24 -0
  63. package/templates/frontend/tanstack/src/components/ui/skeleton.tsx +13 -0
  64. package/templates/frontend/tanstack/src/components/ui/spinner.tsx +10 -0
  65. package/templates/frontend/tanstack/src/lib/utils.ts +1 -6
  66. package/templates/frontend/tanstack/src/router.tsx +31 -31
  67. package/templates/frontend/tanstack/src/routes/__root.tsx +69 -69
  68. package/templates/frontend/tanstack/src/routes/index.tsx.hbs +64 -45
  69. package/templates/frontend/tanstack/src/styles/app.css +100 -55
  70. package/templates/frontend/tanstack/tsconfig.json +22 -22
  71. package/templates/modules/agents/AGENTS.md.hbs +245 -0
  72. package/templates/modules/agents/CLAUDE.md +1 -0
  73. package/templates/modules/agents/config.json +10 -0
  74. package/templates/modules/auth/express/config.json +12 -11
  75. package/templates/modules/auth/express/src/lib/auth.ts.hbs +143 -0
  76. package/templates/modules/auth/express/src/lib/email.ts +37 -0
  77. package/templates/modules/auth/express/src/middleware/requireAuth.ts +29 -0
  78. package/templates/modules/auth/express/src/routes/me.ts +13 -0
  79. package/templates/modules/auth/nestjs/config.json +13 -11
  80. package/templates/modules/auth/nestjs/src/auth/auth.module.ts.hbs +64 -14
  81. package/templates/modules/auth/nestjs/src/auth/auth.ts.hbs +152 -0
  82. package/templates/modules/auth/nestjs/src/auth/email.ts +37 -0
  83. package/templates/modules/auth/nestjs/src/me/me.controller.ts +15 -0
  84. package/templates/modules/auth/nextjs/app/api/auth/[...all]/route.ts +4 -4
  85. package/templates/modules/auth/nextjs/app/dashboard/page.tsx +101 -45
  86. package/templates/modules/auth/nextjs/app/forgot-password/page.tsx +11 -0
  87. package/templates/modules/auth/nextjs/app/reset-password/page.tsx +17 -0
  88. package/templates/modules/auth/nextjs/app/sign-in/page.tsx +23 -17
  89. package/templates/modules/auth/nextjs/app/sign-up/page.tsx +25 -19
  90. package/templates/modules/auth/nextjs/components/auth/change-password-form.tsx +125 -0
  91. package/templates/modules/auth/nextjs/components/auth/email-verification-card.tsx +91 -0
  92. package/templates/modules/auth/nextjs/components/auth/forgot-password-form.tsx +133 -0
  93. package/templates/modules/auth/nextjs/components/auth/reset-password-form.tsx +155 -0
  94. package/templates/modules/auth/nextjs/components/auth/sign-in-form.tsx +46 -32
  95. package/templates/modules/auth/nextjs/components/auth/sign-out-button.tsx +6 -5
  96. package/templates/modules/auth/nextjs/components/auth/sign-up-form.tsx +36 -30
  97. package/templates/modules/auth/nextjs/components/auth/social-buttons.tsx +73 -0
  98. package/templates/modules/auth/nextjs/config.json +24 -18
  99. package/templates/modules/auth/nextjs/lib/auth-client.ts +3 -3
  100. package/templates/modules/auth/nextjs/lib/auth-schema.ts +27 -2
  101. package/templates/modules/auth/nextjs/lib/auth.ts.hbs +65 -0
  102. package/templates/modules/auth/nextjs/lib/email.ts +43 -0
  103. package/templates/modules/auth/nextjs/lib/session.ts +12 -0
  104. package/templates/modules/auth/tanstack/config.json +25 -19
  105. package/templates/modules/auth/tanstack/src/components/auth/change-password-form.tsx +123 -0
  106. package/templates/modules/auth/tanstack/src/components/auth/email-verification-card.tsx +89 -0
  107. package/templates/modules/auth/tanstack/src/components/auth/forgot-password-form.tsx +131 -0
  108. package/templates/modules/auth/tanstack/src/components/auth/reset-password-form.tsx +149 -0
  109. package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +44 -35
  110. package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +7 -6
  111. package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +37 -34
  112. package/templates/modules/auth/tanstack/src/components/auth/social-buttons.tsx +71 -0
  113. package/templates/modules/auth/tanstack/src/lib/auth-client.ts +2 -2
  114. package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +14 -8
  115. package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +27 -2
  116. package/templates/modules/auth/tanstack/src/lib/auth.ts.hbs +98 -38
  117. package/templates/modules/auth/tanstack/src/lib/email.ts +43 -0
  118. package/templates/modules/auth/tanstack/src/routeTree.gen.ts +61 -3
  119. package/templates/modules/auth/tanstack/src/routes/api/auth/$.ts +15 -15
  120. package/templates/modules/auth/tanstack/src/routes/dashboard.tsx +119 -111
  121. package/templates/modules/auth/tanstack/src/routes/forgot-password.tsx +17 -0
  122. package/templates/modules/auth/tanstack/src/routes/reset-password.tsx +25 -0
  123. package/templates/modules/auth/tanstack/src/routes/sign-in.tsx +44 -37
  124. package/templates/modules/auth/tanstack/src/routes/sign-up.tsx +44 -37
  125. package/templates/modules/docker/.dockerignore +2 -0
  126. package/templates/modules/docker/config.json +15 -15
  127. package/templates/modules/drizzle/express/config.json +26 -26
  128. package/templates/modules/drizzle/express/src/lib/schema.ts.hbs +90 -0
  129. package/templates/modules/drizzle/nestjs/config.json +26 -26
  130. package/templates/modules/drizzle/nestjs/src/database/schema.ts.hbs +90 -0
  131. package/templates/modules/drizzle/nextjs/config.json +26 -26
  132. package/templates/modules/drizzle/nextjs/drizzle.config.ts +13 -13
  133. package/templates/modules/drizzle/tanstack/config.json +26 -26
  134. package/templates/modules/drizzle/tanstack/drizzle.config.ts +12 -12
  135. package/templates/modules/drizzle/tanstack/src/lib/db.ts +13 -13
  136. package/templates/modules/mongoose/express/config.json +15 -15
  137. package/templates/modules/mongoose/express/src/lib/db.ts +43 -43
  138. package/templates/modules/mongoose/express/src/models/User.ts +48 -48
  139. package/templates/modules/mongoose/nestjs/config.json +16 -15
  140. package/templates/modules/mongoose/nextjs/config.json +15 -15
  141. package/templates/modules/mongoose/nextjs/models/User.ts +48 -48
  142. package/templates/modules/mongoose/tanstack/config.json +16 -16
  143. package/templates/modules/mongoose/tanstack/src/models/User.ts +48 -48
  144. package/templates/modules/prisma/express/config.json +27 -27
  145. package/templates/modules/prisma/express/prisma/schema.prisma.hbs +92 -0
  146. package/templates/modules/prisma/nestjs/config.json +27 -27
  147. package/templates/modules/prisma/nestjs/prisma/schema.prisma.hbs +91 -0
  148. package/templates/modules/prisma/nextjs/config.json +28 -28
  149. package/templates/modules/prisma/nextjs/lib/prisma.ts +18 -18
  150. package/templates/modules/prisma/nextjs/prisma.config.ts +14 -14
  151. package/templates/modules/prisma/tanstack/config.json +28 -28
  152. package/templates/modules/prisma/tanstack/prisma/schema.prisma.hbs +91 -91
  153. package/templates/modules/prisma/tanstack/prisma.config.ts +14 -14
  154. package/templates/modules/prisma/tanstack/src/lib/prisma.ts +17 -17
  155. package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +0 -8
  156. package/templates/modules/vscode/.vscode/extensions.json.hbs +29 -0
  157. package/templates/modules/vscode/.vscode/settings.json.hbs +22 -0
  158. package/templates/modules/vscode/config.json +10 -0
  159. package/templates/modules/auth/express/src/controllers/authController.ts.hbs +0 -116
  160. package/templates/modules/auth/express/src/lib/jwt.ts.hbs +0 -27
  161. package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +0 -25
  162. package/templates/modules/auth/express/src/routes/auth.ts.hbs +0 -27
  163. package/templates/modules/auth/express/src/services/userStore.ts.hbs +0 -117
  164. package/templates/modules/auth/nestjs/src/auth/auth.controller.ts.hbs +0 -61
  165. package/templates/modules/auth/nestjs/src/auth/auth.guard.ts +0 -36
  166. package/templates/modules/auth/nestjs/src/auth/auth.schemas.ts +0 -35
  167. package/templates/modules/auth/nestjs/src/auth/auth.service.ts +0 -70
  168. package/templates/modules/auth/nestjs/src/auth/jwt.ts +0 -27
  169. package/templates/modules/auth/nestjs/src/auth/users.service.ts.hbs +0 -144
  170. package/templates/modules/auth/nestjs/src/auth/zod-validation.pipe.ts +0 -16
  171. package/templates/modules/drizzle/express/src/lib/schema.ts +0 -12
  172. package/templates/modules/drizzle/nestjs/src/database/schema.ts +0 -12
  173. package/templates/modules/prisma/express/prisma/schema.prisma +0 -24
  174. package/templates/modules/prisma/nestjs/prisma/schema.prisma +0 -23
@@ -1,37 +1,44 @@
1
- import { createFileRoute, redirect } from "@tanstack/react-router";
2
-
3
- import { SignInForm } from "~/components/auth/sign-in-form";
4
- import { getSession } from "~/lib/auth-functions";
5
-
6
- export const Route = createFileRoute("/sign-in")({
7
- beforeLoad: async () => {
8
- const session = await getSession();
9
-
10
- if (session) {
11
- throw redirect({ to: "/dashboard" });
12
- }
13
- },
14
- component: SignInPage,
15
- });
16
-
17
- function SignInPage() {
18
- return (
19
- <main className="min-h-screen bg-[radial-gradient(circle_at_top,_rgba(14,165,233,0.16),_transparent_30%),linear-gradient(180deg,_#f8fafc_0%,_#eef2ff_100%)] px-6 py-16 sm:px-10">
20
- <div className="mx-auto flex min-h-[calc(100vh-8rem)] max-w-5xl items-center gap-12 lg:grid lg:grid-cols-[0.9fr_1.1fr]">
21
- <section className="hidden space-y-5 lg:block">
22
- <span className="inline-flex rounded-full border border-sky-200 bg-white/80 px-3 py-1 text-xs font-medium uppercase tracking-[0.24em] text-sky-700">
23
- Better Auth
24
- </span>
25
- <h1 className="text-4xl font-semibold tracking-tight text-slate-950">
26
- Welcome back.
27
- </h1>
28
- <p className="max-w-md text-base leading-7 text-slate-600">
29
- This generated starter includes protected routes, session-aware page
30
- guards, and reusable auth form primitives you can extend from here.
31
- </p>
32
- </section>
33
- <SignInForm />
34
- </div>
35
- </main>
36
- );
37
- }
1
+ import { createFileRoute, redirect } from "@tanstack/react-router";
2
+
3
+ import { SignInForm } from "~/components/auth/sign-in-form";
4
+ import { Badge } from "~/components/ui/badge";
5
+ import { getSession, getSocialProviders } from "~/lib/auth-functions";
6
+
7
+ export const Route = createFileRoute("/sign-in")({
8
+ beforeLoad: async () => {
9
+ // Two independent server calls, made at the same time
10
+ const [session, providers] = await Promise.all([
11
+ getSession(),
12
+ getSocialProviders(),
13
+ ]);
14
+
15
+ if (session) {
16
+ throw redirect({ to: "/dashboard" });
17
+ }
18
+
19
+ return { providers };
20
+ },
21
+ component: SignInPage,
22
+ });
23
+
24
+ function SignInPage() {
25
+ return (
26
+ <main className="flex min-h-svh items-center justify-center bg-muted p-6 md:p-10">
27
+ <div className="grid w-full max-w-5xl items-center gap-12 lg:grid-cols-[0.9fr_1.1fr]">
28
+ <section className="hidden flex-col gap-5 lg:flex">
29
+ <Badge variant="outline">Better Auth</Badge>
30
+ <h1 className="text-4xl font-semibold tracking-tight">
31
+ Welcome back.
32
+ </h1>
33
+ <p className="max-w-md text-base leading-7 text-muted-foreground">
34
+ This generated starter includes protected routes, session-aware page
35
+ guards, and reusable auth form primitives you can extend from here.
36
+ </p>
37
+ </section>
38
+ <SignInForm
39
+ providers={Route.useRouteContext({ select: (ctx) => ctx.providers })}
40
+ />
41
+ </div>
42
+ </main>
43
+ );
44
+ }
@@ -1,37 +1,44 @@
1
- import { createFileRoute, redirect } from "@tanstack/react-router";
2
-
3
- import { SignUpForm } from "~/components/auth/sign-up-form";
4
- import { getSession } from "~/lib/auth-functions";
5
-
6
- export const Route = createFileRoute("/sign-up")({
7
- beforeLoad: async () => {
8
- const session = await getSession();
9
-
10
- if (session) {
11
- throw redirect({ to: "/dashboard" });
12
- }
13
- },
14
- component: SignUpPage,
15
- });
16
-
17
- function SignUpPage() {
18
- return (
19
- <main className="min-h-screen bg-[radial-gradient(circle_at_top,_rgba(56,189,248,0.18),_transparent_28%),linear-gradient(180deg,_#f8fafc_0%,_#ecfeff_100%)] px-6 py-16 sm:px-10">
20
- <div className="mx-auto flex min-h-[calc(100vh-8rem)] max-w-5xl items-center gap-12 lg:grid lg:grid-cols-[0.9fr_1.1fr]">
21
- <section className="hidden space-y-5 lg:block">
22
- <span className="inline-flex rounded-full border border-sky-200 bg-white/80 px-3 py-1 text-xs font-medium uppercase tracking-[0.24em] text-sky-700">
23
- Better Auth
24
- </span>
25
- <h1 className="text-4xl font-semibold tracking-tight text-slate-950">
26
- Create your account.
27
- </h1>
28
- <p className="max-w-md text-base leading-7 text-slate-600">
29
- Start with email and password today, then layer in profile data,
30
- onboarding, and provider-based auth when your product needs it.
31
- </p>
32
- </section>
33
- <SignUpForm />
34
- </div>
35
- </main>
36
- );
37
- }
1
+ import { createFileRoute, redirect } from "@tanstack/react-router";
2
+
3
+ import { SignUpForm } from "~/components/auth/sign-up-form";
4
+ import { Badge } from "~/components/ui/badge";
5
+ import { getSession, getSocialProviders } from "~/lib/auth-functions";
6
+
7
+ export const Route = createFileRoute("/sign-up")({
8
+ beforeLoad: async () => {
9
+ // Two independent server calls, made at the same time
10
+ const [session, providers] = await Promise.all([
11
+ getSession(),
12
+ getSocialProviders(),
13
+ ]);
14
+
15
+ if (session) {
16
+ throw redirect({ to: "/dashboard" });
17
+ }
18
+
19
+ return { providers };
20
+ },
21
+ component: SignUpPage,
22
+ });
23
+
24
+ function SignUpPage() {
25
+ return (
26
+ <main className="flex min-h-svh items-center justify-center bg-muted p-6 md:p-10">
27
+ <div className="grid w-full max-w-5xl items-center gap-12 lg:grid-cols-[0.9fr_1.1fr]">
28
+ <section className="hidden flex-col gap-5 lg:flex">
29
+ <Badge variant="outline">Better Auth</Badge>
30
+ <h1 className="text-4xl font-semibold tracking-tight">
31
+ Create your account.
32
+ </h1>
33
+ <p className="max-w-md text-base leading-7 text-muted-foreground">
34
+ Sign up with email and password, or with GitHub or Google once
35
+ their keys are set. A verification link goes to your inbox.
36
+ </p>
37
+ </section>
38
+ <SignUpForm
39
+ providers={Route.useRouteContext({ select: (ctx) => ctx.providers })}
40
+ />
41
+ </div>
42
+ </main>
43
+ );
44
+ }
@@ -5,6 +5,8 @@ npm-debug.log
5
5
  .github
6
6
  .gitignore
7
7
  README.md
8
+ AGENTS.md
9
+ CLAUDE.md
8
10
  .vscode
9
11
  .idea
10
12
  dist
@@ -1,15 +1,15 @@
1
- {
2
- "id": "docker",
3
- "name": "Docker",
4
- "description": "Docker containerization with multi-stage build and docker-compose",
5
- "type": "feature",
6
- "dependencies": {},
7
- "devDependencies": {},
8
- "scripts": {
9
- "docker:build": "docker build -t {{projectName}} .",
10
- "docker:up": "docker compose up -d --build",
11
- "docker:down": "docker compose down",
12
- "docker:logs": "docker compose logs -f"
13
- },
14
- "envVars": {}
15
- }
1
+ {
2
+ "id": "docker",
3
+ "name": "Docker",
4
+ "description": "Docker containerization with multi-stage build and docker-compose",
5
+ "type": "feature",
6
+ "dependencies": {},
7
+ "devDependencies": {},
8
+ "scripts": {
9
+ "docker:build": "docker build -t {{projectName}} .",
10
+ "docker:up": "docker compose up -d --build",
11
+ "docker:down": "docker compose down",
12
+ "docker:logs": "docker compose logs -f"
13
+ },
14
+ "envVars": {}
15
+ }
@@ -1,26 +1,26 @@
1
- {
2
- "id": "drizzle",
3
- "name": "Drizzle ORM",
4
- "description": "Drizzle ORM for Express with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "drizzle-orm": "^0.45.4",
8
- "pg": "^8.23.1",
9
- "dotenv": "^17.4.2"
10
- },
11
- "devDependencies": {
12
- "drizzle-kit": "^0.31.11",
13
- "@types/pg": "^8.23.1"
14
- },
15
- "scripts": {
16
- "db:generate": "drizzle-kit generate",
17
- "db:migrate": "drizzle-kit migrate",
18
- "db:studio": "drizzle-kit studio"
19
- },
20
- "envVars": {
21
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
- },
23
- "overrides": {
24
- "esbuild": "^0.28.2"
25
- }
26
- }
1
+ {
2
+ "id": "drizzle",
3
+ "name": "Drizzle ORM",
4
+ "description": "Drizzle ORM for Express with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "drizzle-orm": "^0.45.4",
8
+ "pg": "^8.23.1",
9
+ "dotenv": "^17.4.2"
10
+ },
11
+ "devDependencies": {
12
+ "drizzle-kit": "^0.31.11",
13
+ "@types/pg": "^8.23.1"
14
+ },
15
+ "scripts": {
16
+ "db:generate": "drizzle-kit generate",
17
+ "db:migrate": "drizzle-kit migrate",
18
+ "db:studio": "drizzle-kit studio"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
+ },
23
+ "overrides": {
24
+ "esbuild": "^0.28.2"
25
+ }
26
+ }
@@ -0,0 +1,90 @@
1
+ {{#if useAuth}}
2
+ import { boolean, pgTable, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
3
+
4
+ export const user = pgTable("user", {
5
+ id: text("id").primaryKey(),
6
+ name: text("name").notNull(),
7
+ email: text("email").notNull().unique(),
8
+ emailVerified: boolean("email_verified").notNull().default(false),
9
+ image: text("image"),
10
+ createdAt: timestamp("created_at", { withTimezone: true })
11
+ .notNull()
12
+ .defaultNow(),
13
+ updatedAt: timestamp("updated_at", { withTimezone: true })
14
+ .notNull()
15
+ .defaultNow()
16
+ .$onUpdate(() => new Date()),
17
+ });
18
+
19
+ export const session = pgTable("session", {
20
+ id: text("id").primaryKey(),
21
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
22
+ token: text("token").notNull().unique(),
23
+ createdAt: timestamp("created_at", { withTimezone: true })
24
+ .notNull()
25
+ .defaultNow(),
26
+ updatedAt: timestamp("updated_at", { withTimezone: true })
27
+ .notNull()
28
+ .defaultNow()
29
+ .$onUpdate(() => new Date()),
30
+ ipAddress: text("ip_address"),
31
+ userAgent: text("user_agent"),
32
+ userId: text("user_id")
33
+ .notNull()
34
+ .references(() => user.id, { onDelete: "cascade" }),
35
+ });
36
+
37
+ export const account = pgTable("account", {
38
+ id: text("id").primaryKey(),
39
+ accountId: text("account_id").notNull(),
40
+ providerId: text("provider_id").notNull(),
41
+ userId: text("user_id")
42
+ .notNull()
43
+ .references(() => user.id, { onDelete: "cascade" }),
44
+ accessToken: text("access_token"),
45
+ refreshToken: text("refresh_token"),
46
+ idToken: text("id_token"),
47
+ accessTokenExpiresAt: timestamp("access_token_expires_at", {
48
+ withTimezone: true,
49
+ }),
50
+ refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
51
+ withTimezone: true,
52
+ }),
53
+ scope: text("scope"),
54
+ password: text("password"),
55
+ createdAt: timestamp("created_at", { withTimezone: true })
56
+ .notNull()
57
+ .defaultNow(),
58
+ updatedAt: timestamp("updated_at", { withTimezone: true })
59
+ .notNull()
60
+ .defaultNow()
61
+ .$onUpdate(() => new Date()),
62
+ }, (table) => [uniqueIndex("account_provider_account_id_unique").on(table.providerId, table.accountId)]);
63
+
64
+ export const verification = pgTable("verification", {
65
+ id: text("id").primaryKey(),
66
+ identifier: text("identifier").notNull(),
67
+ value: text("value").notNull(),
68
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
69
+ createdAt: timestamp("created_at", { withTimezone: true })
70
+ .notNull()
71
+ .defaultNow(),
72
+ updatedAt: timestamp("updated_at", { withTimezone: true })
73
+ .notNull()
74
+ .defaultNow()
75
+ .$onUpdate(() => new Date()),
76
+ });
77
+ {{else}}
78
+ import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
79
+
80
+ export const users = pgTable("users", {
81
+ id: uuid("id").primaryKey().defaultRandom(),
82
+ email: text("email").notNull().unique(),
83
+ name: text("name"),
84
+ password: text("password").notNull(),
85
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
86
+ updatedAt: timestamp("updated_at", { withTimezone: true })
87
+ .defaultNow()
88
+ .$onUpdate(() => new Date()),
89
+ });
90
+ {{/if}}
@@ -1,26 +1,26 @@
1
- {
2
- "id": "drizzle",
3
- "name": "Drizzle ORM",
4
- "description": "Drizzle ORM for NestJS with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "drizzle-orm": "^0.45.4",
8
- "pg": "^8.23.1",
9
- "dotenv": "^17.4.2"
10
- },
11
- "devDependencies": {
12
- "drizzle-kit": "^0.31.11",
13
- "@types/pg": "^8.23.1"
14
- },
15
- "scripts": {
16
- "db:generate": "drizzle-kit generate",
17
- "db:migrate": "drizzle-kit migrate",
18
- "db:studio": "drizzle-kit studio"
19
- },
20
- "envVars": {
21
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
- },
23
- "overrides": {
24
- "esbuild": "^0.28.2"
25
- }
26
- }
1
+ {
2
+ "id": "drizzle",
3
+ "name": "Drizzle ORM",
4
+ "description": "Drizzle ORM for NestJS with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "drizzle-orm": "^0.45.4",
8
+ "pg": "^8.23.1",
9
+ "dotenv": "^17.4.2"
10
+ },
11
+ "devDependencies": {
12
+ "drizzle-kit": "^0.31.11",
13
+ "@types/pg": "^8.23.1"
14
+ },
15
+ "scripts": {
16
+ "db:generate": "drizzle-kit generate",
17
+ "db:migrate": "drizzle-kit migrate",
18
+ "db:studio": "drizzle-kit studio"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
+ },
23
+ "overrides": {
24
+ "esbuild": "^0.28.2"
25
+ }
26
+ }
@@ -0,0 +1,90 @@
1
+ {{#if useAuth}}
2
+ import { boolean, pgTable, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
3
+
4
+ export const user = pgTable("user", {
5
+ id: text("id").primaryKey(),
6
+ name: text("name").notNull(),
7
+ email: text("email").notNull().unique(),
8
+ emailVerified: boolean("email_verified").notNull().default(false),
9
+ image: text("image"),
10
+ createdAt: timestamp("created_at", { withTimezone: true })
11
+ .notNull()
12
+ .defaultNow(),
13
+ updatedAt: timestamp("updated_at", { withTimezone: true })
14
+ .notNull()
15
+ .defaultNow()
16
+ .$onUpdate(() => new Date()),
17
+ });
18
+
19
+ export const session = pgTable("session", {
20
+ id: text("id").primaryKey(),
21
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
22
+ token: text("token").notNull().unique(),
23
+ createdAt: timestamp("created_at", { withTimezone: true })
24
+ .notNull()
25
+ .defaultNow(),
26
+ updatedAt: timestamp("updated_at", { withTimezone: true })
27
+ .notNull()
28
+ .defaultNow()
29
+ .$onUpdate(() => new Date()),
30
+ ipAddress: text("ip_address"),
31
+ userAgent: text("user_agent"),
32
+ userId: text("user_id")
33
+ .notNull()
34
+ .references(() => user.id, { onDelete: "cascade" }),
35
+ });
36
+
37
+ export const account = pgTable("account", {
38
+ id: text("id").primaryKey(),
39
+ accountId: text("account_id").notNull(),
40
+ providerId: text("provider_id").notNull(),
41
+ userId: text("user_id")
42
+ .notNull()
43
+ .references(() => user.id, { onDelete: "cascade" }),
44
+ accessToken: text("access_token"),
45
+ refreshToken: text("refresh_token"),
46
+ idToken: text("id_token"),
47
+ accessTokenExpiresAt: timestamp("access_token_expires_at", {
48
+ withTimezone: true,
49
+ }),
50
+ refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
51
+ withTimezone: true,
52
+ }),
53
+ scope: text("scope"),
54
+ password: text("password"),
55
+ createdAt: timestamp("created_at", { withTimezone: true })
56
+ .notNull()
57
+ .defaultNow(),
58
+ updatedAt: timestamp("updated_at", { withTimezone: true })
59
+ .notNull()
60
+ .defaultNow()
61
+ .$onUpdate(() => new Date()),
62
+ }, (table) => [uniqueIndex("account_provider_account_id_unique").on(table.providerId, table.accountId)]);
63
+
64
+ export const verification = pgTable("verification", {
65
+ id: text("id").primaryKey(),
66
+ identifier: text("identifier").notNull(),
67
+ value: text("value").notNull(),
68
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
69
+ createdAt: timestamp("created_at", { withTimezone: true })
70
+ .notNull()
71
+ .defaultNow(),
72
+ updatedAt: timestamp("updated_at", { withTimezone: true })
73
+ .notNull()
74
+ .defaultNow()
75
+ .$onUpdate(() => new Date()),
76
+ });
77
+ {{else}}
78
+ import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
79
+
80
+ export const users = pgTable("users", {
81
+ id: uuid("id").primaryKey().defaultRandom(),
82
+ email: text("email").notNull().unique(),
83
+ name: text("name"),
84
+ password: text("password").notNull(),
85
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
86
+ updatedAt: timestamp("updated_at", { withTimezone: true })
87
+ .defaultNow()
88
+ .$onUpdate(() => new Date()),
89
+ });
90
+ {{/if}}
@@ -1,26 +1,26 @@
1
- {
2
- "id": "drizzle",
3
- "name": "Drizzle ORM",
4
- "description": "Drizzle ORM for Next.js with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "drizzle-orm": "^0.45.4",
8
- "pg": "^8.23.1",
9
- "dotenv": "^17.4.2"
10
- },
11
- "devDependencies": {
12
- "drizzle-kit": "^0.31.11",
13
- "@types/pg": "^8.23.1"
14
- },
15
- "scripts": {
16
- "db:generate": "drizzle-kit generate",
17
- "db:migrate": "drizzle-kit migrate",
18
- "db:studio": "drizzle-kit studio"
19
- },
20
- "envVars": {
21
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
- },
23
- "overrides": {
24
- "esbuild": "^0.28.2"
25
- }
26
- }
1
+ {
2
+ "id": "drizzle",
3
+ "name": "Drizzle ORM",
4
+ "description": "Drizzle ORM for Next.js with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "drizzle-orm": "^0.45.4",
8
+ "pg": "^8.23.1",
9
+ "dotenv": "^17.4.2"
10
+ },
11
+ "devDependencies": {
12
+ "drizzle-kit": "^0.31.11",
13
+ "@types/pg": "^8.23.1"
14
+ },
15
+ "scripts": {
16
+ "db:generate": "drizzle-kit generate",
17
+ "db:migrate": "drizzle-kit migrate",
18
+ "db:studio": "drizzle-kit studio"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
+ },
23
+ "overrides": {
24
+ "esbuild": "^0.28.2"
25
+ }
26
+ }
@@ -1,13 +1,13 @@
1
- import { config } from "dotenv";
2
- import { defineConfig } from "drizzle-kit";
3
-
4
- config({ path: ".env" });
5
-
6
- export default defineConfig({
7
- schema: "./lib/schema.ts",
8
- out: "./migrations",
9
- dialect: "postgresql",
10
- dbCredentials: {
11
- url: process.env.DATABASE_URL!,
12
- },
13
- });
1
+ import { config } from "dotenv";
2
+ import { defineConfig } from "drizzle-kit";
3
+
4
+ config({ path: ".env" });
5
+
6
+ export default defineConfig({
7
+ schema: "./lib/schema.ts",
8
+ out: "./migrations",
9
+ dialect: "postgresql",
10
+ dbCredentials: {
11
+ url: process.env.DATABASE_URL!,
12
+ },
13
+ });
@@ -1,26 +1,26 @@
1
- {
2
- "id": "drizzle",
3
- "name": "Drizzle ORM",
4
- "description": "Drizzle ORM for TanStack Start with PostgreSQL",
5
- "type": "database",
6
- "dependencies": {
7
- "drizzle-orm": "^0.45.4",
8
- "pg": "^8.23.1",
9
- "dotenv": "^17.4.2"
10
- },
11
- "devDependencies": {
12
- "drizzle-kit": "^0.31.11",
13
- "@types/pg": "^8.23.1"
14
- },
15
- "scripts": {
16
- "db:generate": "drizzle-kit generate",
17
- "db:migrate": "drizzle-kit migrate",
18
- "db:studio": "drizzle-kit studio"
19
- },
20
- "envVars": {
21
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
- },
23
- "overrides": {
24
- "esbuild": "^0.28.2"
25
- }
26
- }
1
+ {
2
+ "id": "drizzle",
3
+ "name": "Drizzle ORM",
4
+ "description": "Drizzle ORM for TanStack Start with PostgreSQL",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "drizzle-orm": "^0.45.4",
8
+ "pg": "^8.23.1",
9
+ "dotenv": "^17.4.2"
10
+ },
11
+ "devDependencies": {
12
+ "drizzle-kit": "^0.31.11",
13
+ "@types/pg": "^8.23.1"
14
+ },
15
+ "scripts": {
16
+ "db:generate": "drizzle-kit generate",
17
+ "db:migrate": "drizzle-kit migrate",
18
+ "db:studio": "drizzle-kit studio"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
+ },
23
+ "overrides": {
24
+ "esbuild": "^0.28.2"
25
+ }
26
+ }
@@ -1,13 +1,13 @@
1
- import { defineConfig } from "drizzle-kit";
2
- import { config } from "dotenv";
3
-
4
- config({ path: ".env" });
5
-
6
- export default defineConfig({
7
- schema: "./src/lib/schema.ts",
8
- out: "./migrations",
9
- dialect: "postgresql",
10
- dbCredentials: {
11
- url: process.env.DATABASE_URL!,
12
- },
1
+ import { defineConfig } from "drizzle-kit";
2
+ import { config } from "dotenv";
3
+
4
+ config({ path: ".env" });
5
+
6
+ export default defineConfig({
7
+ schema: "./src/lib/schema.ts",
8
+ out: "./migrations",
9
+ dialect: "postgresql",
10
+ dbCredentials: {
11
+ url: process.env.DATABASE_URL!,
12
+ },
13
13
  });