better-ts-stack 2.0.0 → 2.0.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 (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/args.js +2 -2
  4. package/dist/builder/buildPlanner.js +71 -0
  5. package/dist/builder/configGenerator.js +9 -7
  6. package/dist/builder/dependencyInstaller.js +0 -1
  7. package/dist/builder/fileProcessor.js +47 -44
  8. package/dist/builder/gitInitializer.js +20 -1
  9. package/dist/builder/index.js +19 -38
  10. package/dist/builder/moduleSelector.js +0 -1
  11. package/dist/builder/templateContext.js +0 -22
  12. package/dist/index.js +4 -3
  13. package/dist/modules/registry.js +4 -6
  14. package/dist/output/nextSteps.js +4 -3
  15. package/dist/prompts/index.js +0 -1
  16. package/dist/prompts/stack.js +4 -1
  17. package/dist/types/index.js +8 -4
  18. package/dist/ui/index.js +0 -1
  19. package/dist/ui/messages.js +25 -1
  20. package/dist/ui/prompts.js +0 -1
  21. package/dist/ui/theme.js +0 -1
  22. package/dist/validators/index.js +10 -41
  23. package/package.json +2 -1
  24. package/templates/backend/express/.prettierrc +2 -2
  25. package/templates/backend/express/config.json +1 -5
  26. package/templates/backend/express/eslint.config.mjs +40 -40
  27. package/templates/backend/express/gitignore +36 -36
  28. package/templates/backend/express/src/{index.ts → index.ts.hbs} +28 -29
  29. package/templates/backend/express/src/routes/health.ts +12 -12
  30. package/templates/backend/express/tsconfig.json +25 -25
  31. package/templates/backend/nestjs/.prettierrc +16 -16
  32. package/templates/backend/nestjs/config.json +1 -4
  33. package/templates/backend/nestjs/eslint.config.mjs +40 -40
  34. package/templates/backend/nestjs/gitignore +36 -36
  35. package/templates/backend/nestjs/nest-cli.json +9 -9
  36. package/templates/backend/nestjs/src/app.module.ts.hbs +34 -34
  37. package/templates/backend/nestjs/src/health/health.controller.ts +12 -12
  38. package/templates/backend/nestjs/src/main.ts +23 -23
  39. package/templates/backend/nestjs/tsconfig.json +25 -25
  40. package/templates/frontend/nextjs/components.json +19 -19
  41. package/templates/frontend/nextjs/config.json +1 -2
  42. package/templates/frontend/nextjs/gitignore +42 -42
  43. package/templates/frontend/nextjs/lib/utils.ts +6 -6
  44. package/templates/frontend/nextjs/proxy.ts.hbs +24 -24
  45. package/templates/frontend/nextjs/tsconfig.json +34 -34
  46. package/templates/frontend/tanstack/config.json +45 -48
  47. package/templates/frontend/tanstack/src/routeTree.gen.ts +68 -68
  48. package/templates/frontend/tanstack/src/styles/app.css +85 -85
  49. package/templates/modules/auth/express/config.json +1 -8
  50. package/templates/modules/auth/express/src/controllers/authController.ts.hbs +116 -116
  51. package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +26 -26
  52. package/templates/modules/auth/express/src/services/userStore.ts.hbs +117 -117
  53. package/templates/modules/auth/nestjs/config.json +1 -5
  54. package/templates/modules/auth/nestjs/src/auth/auth.controller.ts +46 -46
  55. package/templates/modules/auth/nestjs/src/auth/auth.guard.ts +36 -36
  56. package/templates/modules/auth/nestjs/src/auth/auth.module.ts.hbs +22 -22
  57. package/templates/modules/auth/nestjs/src/auth/auth.schemas.ts +35 -35
  58. package/templates/modules/auth/nestjs/src/auth/auth.service.ts +70 -70
  59. package/templates/modules/auth/nestjs/src/auth/jwt.ts +27 -27
  60. package/templates/modules/auth/nestjs/src/auth/users.service.ts.hbs +144 -144
  61. package/templates/modules/auth/nestjs/src/auth/zod-validation.pipe.ts +16 -16
  62. package/templates/modules/auth/nextjs/app/dashboard/page.tsx +96 -96
  63. package/templates/modules/auth/nextjs/app/sign-in/page.tsx +35 -35
  64. package/templates/modules/auth/nextjs/app/sign-up/page.tsx +35 -35
  65. package/templates/modules/auth/nextjs/components/auth/sign-in-form.tsx +132 -132
  66. package/templates/modules/auth/nextjs/components/auth/sign-out-button.tsx +50 -50
  67. package/templates/modules/auth/nextjs/components/auth/sign-up-form.tsx +152 -152
  68. package/templates/modules/auth/nextjs/config.json +2 -15
  69. package/templates/modules/auth/nextjs/lib/auth-schema.ts +39 -39
  70. package/templates/modules/auth/nextjs/lib/auth.ts.hbs +37 -37
  71. package/templates/modules/auth/tanstack/config.json +2 -16
  72. package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +4 -4
  73. package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +38 -38
  74. package/templates/modules/auth/tanstack/src/routeTree.gen.ts +140 -140
  75. package/templates/modules/docker/.dockerignore +14 -14
  76. package/templates/modules/docker/Dockerfile.hbs +1 -3
  77. package/templates/modules/docker/config.json +1 -5
  78. package/templates/modules/docker/docker-compose.yml.hbs +9 -9
  79. package/templates/modules/drizzle/express/config.json +1 -2
  80. package/templates/modules/drizzle/express/drizzle.config.ts +13 -13
  81. package/templates/modules/drizzle/express/src/lib/db.ts +13 -13
  82. package/templates/modules/drizzle/express/src/lib/schema.ts +12 -10
  83. package/templates/modules/drizzle/nestjs/config.json +1 -2
  84. package/templates/modules/drizzle/nestjs/drizzle.config.ts +13 -13
  85. package/templates/modules/drizzle/nestjs/src/database/database.module.ts +30 -30
  86. package/templates/modules/drizzle/nestjs/src/database/schema.ts +12 -10
  87. package/templates/modules/drizzle/nextjs/config.json +1 -4
  88. package/templates/modules/drizzle/nextjs/lib/db.ts +13 -13
  89. package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +90 -84
  90. package/templates/modules/drizzle/tanstack/config.json +5 -5
  91. package/templates/modules/drizzle/tanstack/src/lib/schema.ts.hbs +90 -84
  92. package/templates/modules/mongoose/express/config.json +1 -2
  93. package/templates/modules/mongoose/nestjs/config.json +1 -2
  94. package/templates/modules/mongoose/nestjs/src/users/user.schema.ts +21 -21
  95. package/templates/modules/mongoose/nextjs/config.json +1 -2
  96. package/templates/modules/mongoose/nextjs/lib/db.ts +36 -36
  97. package/templates/modules/mongoose/tanstack/config.json +1 -2
  98. package/templates/modules/mongoose/tanstack/src/lib/db.ts +37 -37
  99. package/templates/modules/prisma/express/config.json +0 -1
  100. package/templates/modules/prisma/express/prisma/schema.prisma +1 -1
  101. package/templates/modules/prisma/express/prisma.config.ts +12 -12
  102. package/templates/modules/prisma/express/src/lib/prisma.ts +24 -24
  103. package/templates/modules/prisma/nestjs/config.json +0 -1
  104. package/templates/modules/prisma/nestjs/prisma/schema.prisma +23 -23
  105. package/templates/modules/prisma/nestjs/prisma.config.ts +12 -12
  106. package/templates/modules/prisma/nestjs/src/prisma/prisma.module.ts +11 -11
  107. package/templates/modules/prisma/nestjs/src/prisma/prisma.service.ts +17 -17
  108. package/templates/modules/prisma/nextjs/config.json +0 -1
  109. package/templates/modules/prisma/nextjs/prisma/schema.prisma.hbs +91 -91
  110. package/templates/modules/prisma/tanstack/config.json +0 -1
  111. package/dist/args.d.ts +0 -12
  112. package/dist/args.d.ts.map +0 -1
  113. package/dist/args.js.map +0 -1
  114. package/dist/builder/configGenerator.d.ts +0 -7
  115. package/dist/builder/configGenerator.d.ts.map +0 -1
  116. package/dist/builder/configGenerator.js.map +0 -1
  117. package/dist/builder/dependencyInstaller.d.ts +0 -3
  118. package/dist/builder/dependencyInstaller.d.ts.map +0 -1
  119. package/dist/builder/dependencyInstaller.js.map +0 -1
  120. package/dist/builder/fileProcessor.d.ts +0 -6
  121. package/dist/builder/fileProcessor.d.ts.map +0 -1
  122. package/dist/builder/fileProcessor.js.map +0 -1
  123. package/dist/builder/gitInitializer.d.ts +0 -2
  124. package/dist/builder/gitInitializer.d.ts.map +0 -1
  125. package/dist/builder/gitInitializer.js.map +0 -1
  126. package/dist/builder/index.d.ts +0 -3
  127. package/dist/builder/index.d.ts.map +0 -1
  128. package/dist/builder/index.js.map +0 -1
  129. package/dist/builder/moduleSelector.d.ts +0 -6
  130. package/dist/builder/moduleSelector.d.ts.map +0 -1
  131. package/dist/builder/moduleSelector.js.map +0 -1
  132. package/dist/builder/templateContext.d.ts +0 -6
  133. package/dist/builder/templateContext.d.ts.map +0 -1
  134. package/dist/builder/templateContext.js.map +0 -1
  135. package/dist/index.d.ts +0 -2
  136. package/dist/index.d.ts.map +0 -1
  137. package/dist/index.js.map +0 -1
  138. package/dist/modules/registry.d.ts +0 -6
  139. package/dist/modules/registry.d.ts.map +0 -1
  140. package/dist/modules/registry.js.map +0 -1
  141. package/dist/output/nextSteps.d.ts +0 -3
  142. package/dist/output/nextSteps.d.ts.map +0 -1
  143. package/dist/output/nextSteps.js.map +0 -1
  144. package/dist/prompts/index.d.ts +0 -4
  145. package/dist/prompts/index.d.ts.map +0 -1
  146. package/dist/prompts/index.js.map +0 -1
  147. package/dist/prompts/stack.d.ts +0 -4
  148. package/dist/prompts/stack.d.ts.map +0 -1
  149. package/dist/prompts/stack.js.map +0 -1
  150. package/dist/types/index.d.ts +0 -137
  151. package/dist/types/index.d.ts.map +0 -1
  152. package/dist/types/index.js.map +0 -1
  153. package/dist/ui/index.d.ts +0 -3
  154. package/dist/ui/index.d.ts.map +0 -1
  155. package/dist/ui/index.js.map +0 -1
  156. package/dist/ui/messages.d.ts +0 -9
  157. package/dist/ui/messages.d.ts.map +0 -1
  158. package/dist/ui/messages.js.map +0 -1
  159. package/dist/ui/prompts.d.ts +0 -20
  160. package/dist/ui/prompts.d.ts.map +0 -1
  161. package/dist/ui/prompts.js.map +0 -1
  162. package/dist/ui/theme.d.ts +0 -9
  163. package/dist/ui/theme.d.ts.map +0 -1
  164. package/dist/ui/theme.js.map +0 -1
  165. package/dist/validators/index.d.ts +0 -6
  166. package/dist/validators/index.d.ts.map +0 -1
  167. package/dist/validators/index.js.map +0 -1
@@ -18,11 +18,8 @@
18
18
  "db:studio": "drizzle-kit studio"
19
19
  },
20
20
  "envVars": {
21
- "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb?schema=public"
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
22
  },
23
- "templateFiles": [
24
- "lib/schema.ts.hbs"
25
- ],
26
23
  "overrides": {
27
24
  "esbuild": "^0.28.2"
28
25
  }
@@ -1,13 +1,13 @@
1
- import { config } from "dotenv";
2
- import { drizzle } from "drizzle-orm/node-postgres";
3
- import { Pool } from "pg";
4
-
5
- import * as schema from "./schema";
6
-
7
- config({ path: ".env" }); // or .env.local
8
-
9
- const pool = new Pool({
10
- connectionString: process.env.DATABASE_URL,
11
- });
12
-
13
- export const db = drizzle(pool, { schema });
1
+ import { config } from "dotenv";
2
+ import { drizzle } from "drizzle-orm/node-postgres";
3
+ import { Pool } from "pg";
4
+
5
+ import * as schema from "./schema";
6
+
7
+ config({ path: ".env" }); // or .env.local
8
+
9
+ const pool = new Pool({
10
+ connectionString: process.env.DATABASE_URL,
11
+ });
12
+
13
+ export const db = drizzle(pool, { schema });
@@ -1,84 +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
- });
17
-
18
- export const session = pgTable("session", {
19
- id: text("id").primaryKey(),
20
- expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
21
- token: text("token").notNull().unique(),
22
- createdAt: timestamp("created_at", { withTimezone: true })
23
- .notNull()
24
- .defaultNow(),
25
- updatedAt: timestamp("updated_at", { withTimezone: true })
26
- .notNull()
27
- .defaultNow(),
28
- ipAddress: text("ip_address"),
29
- userAgent: text("user_agent"),
30
- userId: text("user_id")
31
- .notNull()
32
- .references(() => user.id, { onDelete: "cascade" }),
33
- });
34
-
35
- export const account = pgTable("account", {
36
- id: text("id").primaryKey(),
37
- accountId: text("account_id").notNull(),
38
- providerId: text("provider_id").notNull(),
39
- userId: text("user_id")
40
- .notNull()
41
- .references(() => user.id, { onDelete: "cascade" }),
42
- accessToken: text("access_token"),
43
- refreshToken: text("refresh_token"),
44
- idToken: text("id_token"),
45
- accessTokenExpiresAt: timestamp("access_token_expires_at", {
46
- withTimezone: true,
47
- }),
48
- refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
49
- withTimezone: true,
50
- }),
51
- scope: text("scope"),
52
- password: text("password"),
53
- createdAt: timestamp("created_at", { withTimezone: true })
54
- .notNull()
55
- .defaultNow(),
56
- updatedAt: timestamp("updated_at", { withTimezone: true })
57
- .notNull()
58
- .defaultNow(),
59
- }, (table) => [uniqueIndex("account_provider_account_id_unique").on(table.providerId, table.accountId)]);
60
-
61
- export const verification = pgTable("verification", {
62
- id: text("id").primaryKey(),
63
- identifier: text("identifier").notNull(),
64
- value: text("value").notNull(),
65
- expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
66
- createdAt: timestamp("created_at", { withTimezone: true })
67
- .notNull()
68
- .defaultNow(),
69
- updatedAt: timestamp("updated_at", { withTimezone: true })
70
- .notNull()
71
- .defaultNow(),
72
- });
73
- {{else}}
74
- import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
75
-
76
- export const users = pgTable("users", {
77
- id: uuid("id").primaryKey().defaultRandom(),
78
- email: text("email").notNull().unique(),
79
- name: text("name"),
80
- password: text("password").notNull(),
81
- createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
82
- updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
83
- });
84
- {{/if}}
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}}
@@ -18,9 +18,9 @@
18
18
  "db:studio": "drizzle-kit studio"
19
19
  },
20
20
  "envVars": {
21
- "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb?schema=public"
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres"
22
22
  },
23
- "templateFiles": [
24
- "src/lib/schema.ts.hbs"
25
- ]
26
- }
23
+ "overrides": {
24
+ "esbuild": "^0.28.2"
25
+ }
26
+ }
@@ -1,84 +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
- });
17
-
18
- export const session = pgTable("session", {
19
- id: text("id").primaryKey(),
20
- expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
21
- token: text("token").notNull().unique(),
22
- createdAt: timestamp("created_at", { withTimezone: true })
23
- .notNull()
24
- .defaultNow(),
25
- updatedAt: timestamp("updated_at", { withTimezone: true })
26
- .notNull()
27
- .defaultNow(),
28
- ipAddress: text("ip_address"),
29
- userAgent: text("user_agent"),
30
- userId: text("user_id")
31
- .notNull()
32
- .references(() => user.id, { onDelete: "cascade" }),
33
- });
34
-
35
- export const account = pgTable("account", {
36
- id: text("id").primaryKey(),
37
- accountId: text("account_id").notNull(),
38
- providerId: text("provider_id").notNull(),
39
- userId: text("user_id")
40
- .notNull()
41
- .references(() => user.id, { onDelete: "cascade" }),
42
- accessToken: text("access_token"),
43
- refreshToken: text("refresh_token"),
44
- idToken: text("id_token"),
45
- accessTokenExpiresAt: timestamp("access_token_expires_at", {
46
- withTimezone: true,
47
- }),
48
- refreshTokenExpiresAt: timestamp("refresh_token_expires_at", {
49
- withTimezone: true,
50
- }),
51
- scope: text("scope"),
52
- password: text("password"),
53
- createdAt: timestamp("created_at", { withTimezone: true })
54
- .notNull()
55
- .defaultNow(),
56
- updatedAt: timestamp("updated_at", { withTimezone: true })
57
- .notNull()
58
- .defaultNow(),
59
- }, (table) => [uniqueIndex("account_provider_account_id_unique").on(table.providerId, table.accountId)]);
60
-
61
- export const verification = pgTable("verification", {
62
- id: text("id").primaryKey(),
63
- identifier: text("identifier").notNull(),
64
- value: text("value").notNull(),
65
- expiresAt: timestamp("expires_at", { withTimezone: true }).notNull(),
66
- createdAt: timestamp("created_at", { withTimezone: true })
67
- .notNull()
68
- .defaultNow(),
69
- updatedAt: timestamp("updated_at", { withTimezone: true })
70
- .notNull()
71
- .defaultNow(),
72
- });
73
- {{else}}
74
- import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
75
-
76
- export const users = pgTable("users", {
77
- id: uuid("id").primaryKey().defaultRandom(),
78
- email: text("email").notNull().unique(),
79
- name: text("name"),
80
- password: text("password").notNull(),
81
- createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
82
- updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
83
- });
84
- {{/if}}
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}}
@@ -11,6 +11,5 @@
11
11
  "scripts": {},
12
12
  "envVars": {
13
13
  "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- },
15
- "templateFiles": []
14
+ }
16
15
  }
@@ -11,6 +11,5 @@
11
11
  "scripts": {},
12
12
  "envVars": {
13
13
  "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- },
15
- "templateFiles": []
14
+ }
16
15
  }
@@ -1,21 +1,21 @@
1
- import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
2
-
3
- @Schema({ timestamps: true })
4
- export class User {
5
- @Prop({
6
- type: String,
7
- required: true,
8
- unique: true,
9
- lowercase: true,
10
- trim: true,
11
- })
12
- email: string;
13
-
14
- @Prop({ type: String, trim: true })
15
- name?: string | null;
16
-
17
- @Prop({ type: String, required: true })
18
- password: string;
19
- }
20
-
21
- export const UserSchema = SchemaFactory.createForClass(User);
1
+ import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
2
+
3
+ @Schema({ timestamps: true })
4
+ export class User {
5
+ @Prop({
6
+ type: String,
7
+ required: true,
8
+ unique: true,
9
+ lowercase: true,
10
+ trim: true,
11
+ })
12
+ email: string;
13
+
14
+ @Prop({ type: String, trim: true })
15
+ name?: string | null;
16
+
17
+ @Prop({ type: String, required: true })
18
+ password: string;
19
+ }
20
+
21
+ export const UserSchema = SchemaFactory.createForClass(User);
@@ -11,6 +11,5 @@
11
11
  "scripts": {},
12
12
  "envVars": {
13
13
  "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- },
15
- "templateFiles": []
14
+ }
16
15
  }
@@ -1,36 +1,36 @@
1
- import mongoose from "mongoose";
2
-
3
- // Reuse one connection across hot reloads and concurrent requests
4
- const globalForMongoose = globalThis as unknown as {
5
- mongooseConnection?: Promise<typeof mongoose>;
6
- };
7
-
8
- /**
9
- * Connects Mongoose once and returns the shared connection.
10
- * Call this in server code before querying Mongoose models.
11
- */
12
- export async function connectDB(): Promise<typeof mongoose> {
13
- const mongoUri = process.env.MONGODB_URI;
14
-
15
- if (!mongoUri) {
16
- throw new Error("MONGODB_URI environment variable is not defined");
17
- }
18
-
19
- globalForMongoose.mongooseConnection ??= mongoose
20
- .connect(mongoUri)
21
- .catch((error: unknown) => {
22
- // Let the next call retry instead of caching the failure
23
- globalForMongoose.mongooseConnection = undefined;
24
- throw error;
25
- });
26
-
27
- return globalForMongoose.mongooseConnection;
28
- }
29
-
30
- /**
31
- * Gracefully close the MongoDB connection
32
- */
33
- export async function disconnectDB(): Promise<void> {
34
- await mongoose.connection.close();
35
- globalForMongoose.mongooseConnection = undefined;
36
- }
1
+ import mongoose from "mongoose";
2
+
3
+ // Reuse one connection across hot reloads and concurrent requests
4
+ const globalForMongoose = globalThis as unknown as {
5
+ mongooseConnection?: Promise<typeof mongoose>;
6
+ };
7
+
8
+ /**
9
+ * Connects Mongoose once and returns the shared connection.
10
+ * Call this in server code before querying Mongoose models.
11
+ */
12
+ export async function connectDB(): Promise<typeof mongoose> {
13
+ const mongoUri = process.env.MONGODB_URI;
14
+
15
+ if (!mongoUri) {
16
+ throw new Error("MONGODB_URI environment variable is not defined");
17
+ }
18
+
19
+ globalForMongoose.mongooseConnection ??= mongoose
20
+ .connect(mongoUri)
21
+ .catch((error: unknown) => {
22
+ // Let the next call retry instead of caching the failure
23
+ globalForMongoose.mongooseConnection = undefined;
24
+ throw error;
25
+ });
26
+
27
+ return globalForMongoose.mongooseConnection;
28
+ }
29
+
30
+ /**
31
+ * Gracefully close the MongoDB connection
32
+ */
33
+ export async function disconnectDB(): Promise<void> {
34
+ await mongoose.connection.close();
35
+ globalForMongoose.mongooseConnection = undefined;
36
+ }
@@ -12,6 +12,5 @@
12
12
  "scripts": {},
13
13
  "envVars": {
14
14
  "MONGODB_URI": "mongodb://localhost:27017/myapp"
15
- },
16
- "templateFiles": []
15
+ }
17
16
  }
@@ -1,37 +1,37 @@
1
- import "dotenv/config";
2
- import mongoose from "mongoose";
3
-
4
- // Reuse one connection across hot reloads and concurrent requests
5
- const globalForMongoose = globalThis as unknown as {
6
- mongooseConnection?: Promise<typeof mongoose>;
7
- };
8
-
9
- /**
10
- * Connects Mongoose once and returns the shared connection.
11
- * Call this in server code before querying Mongoose models.
12
- */
13
- export async function connectDB(): Promise<typeof mongoose> {
14
- const mongoUri = process.env.MONGODB_URI;
15
-
16
- if (!mongoUri) {
17
- throw new Error("MONGODB_URI environment variable is not defined");
18
- }
19
-
20
- globalForMongoose.mongooseConnection ??= mongoose
21
- .connect(mongoUri)
22
- .catch((error: unknown) => {
23
- // Let the next call retry instead of caching the failure
24
- globalForMongoose.mongooseConnection = undefined;
25
- throw error;
26
- });
27
-
28
- return globalForMongoose.mongooseConnection;
29
- }
30
-
31
- /**
32
- * Gracefully close the MongoDB connection
33
- */
34
- export async function disconnectDB(): Promise<void> {
35
- await mongoose.connection.close();
36
- globalForMongoose.mongooseConnection = undefined;
37
- }
1
+ import "dotenv/config";
2
+ import mongoose from "mongoose";
3
+
4
+ // Reuse one connection across hot reloads and concurrent requests
5
+ const globalForMongoose = globalThis as unknown as {
6
+ mongooseConnection?: Promise<typeof mongoose>;
7
+ };
8
+
9
+ /**
10
+ * Connects Mongoose once and returns the shared connection.
11
+ * Call this in server code before querying Mongoose models.
12
+ */
13
+ export async function connectDB(): Promise<typeof mongoose> {
14
+ const mongoUri = process.env.MONGODB_URI;
15
+
16
+ if (!mongoUri) {
17
+ throw new Error("MONGODB_URI environment variable is not defined");
18
+ }
19
+
20
+ globalForMongoose.mongooseConnection ??= mongoose
21
+ .connect(mongoUri)
22
+ .catch((error: unknown) => {
23
+ // Let the next call retry instead of caching the failure
24
+ globalForMongoose.mongooseConnection = undefined;
25
+ throw error;
26
+ });
27
+
28
+ return globalForMongoose.mongooseConnection;
29
+ }
30
+
31
+ /**
32
+ * Gracefully close the MongoDB connection
33
+ */
34
+ export async function disconnectDB(): Promise<void> {
35
+ await mongoose.connection.close();
36
+ globalForMongoose.mongooseConnection = undefined;
37
+ }
@@ -20,7 +20,6 @@
20
20
  "envVars": {
21
21
  "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
22
22
  },
23
- "templateFiles": [],
24
23
  "overrides": {
25
24
  "deepmerge-ts": "^8.0.2",
26
25
  "mysql2": "^3.24.3"