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,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,15 +1,15 @@
1
- {
2
- "id": "mongoose",
3
- "name": "Mongoose (MongoDB)",
4
- "description": "MongoDB database integration for Express using Mongoose ODM",
5
- "type": "database",
6
- "dependencies": {
7
- "mongoose": "^9.11.4",
8
- "mongodb": "^7.8.0"
9
- },
10
- "devDependencies": {},
11
- "scripts": {},
12
- "envVars": {
13
- "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- }
15
- }
1
+ {
2
+ "id": "mongoose",
3
+ "name": "Mongoose (MongoDB)",
4
+ "description": "MongoDB database integration for Express using Mongoose ODM",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "mongoose": "^9.11.4",
8
+ "mongodb": "^7.8.0"
9
+ },
10
+ "devDependencies": {},
11
+ "scripts": {},
12
+ "envVars": {
13
+ "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
+ }
15
+ }
@@ -1,43 +1,43 @@
1
- import mongoose from "mongoose";
2
-
3
- /**
4
- * MongoDB connection configuration
5
- */
6
- const connectDB = async (): Promise<void> => {
7
- try {
8
- const mongoUri = process.env.MONGODB_URI;
9
-
10
- if (!mongoUri) {
11
- throw new Error("MONGODB_URI environment variable is not defined");
12
- }
13
-
14
- await mongoose.connect(mongoUri);
15
-
16
- console.log("MongoDB connected successfully");
17
-
18
- mongoose.connection.on("error", (error) => {
19
- console.error("MongoDB connection error:", error);
20
- });
21
-
22
- mongoose.connection.on("disconnected", () => {
23
- console.log("MongoDB disconnected");
24
- });
25
- } catch (error) {
26
- console.error("Failed to connect to MongoDB:", error);
27
- process.exit(1);
28
- }
29
- };
30
-
31
- /**
32
- * Gracefully close MongoDB connection
33
- */
34
- const disconnectDB = async (): Promise<void> => {
35
- try {
36
- await mongoose.connection.close();
37
- console.log("MongoDB connection closed");
38
- } catch (error) {
39
- console.error("Error closing MongoDB connection:", error);
40
- }
41
- };
42
-
43
- export { connectDB, disconnectDB };
1
+ import mongoose from "mongoose";
2
+
3
+ /**
4
+ * MongoDB connection configuration
5
+ */
6
+ const connectDB = async (): Promise<void> => {
7
+ try {
8
+ const mongoUri = process.env.MONGODB_URI;
9
+
10
+ if (!mongoUri) {
11
+ throw new Error("MONGODB_URI environment variable is not defined");
12
+ }
13
+
14
+ await mongoose.connect(mongoUri);
15
+
16
+ console.log("MongoDB connected successfully");
17
+
18
+ mongoose.connection.on("error", (error) => {
19
+ console.error("MongoDB connection error:", error);
20
+ });
21
+
22
+ mongoose.connection.on("disconnected", () => {
23
+ console.log("MongoDB disconnected");
24
+ });
25
+ } catch (error) {
26
+ console.error("Failed to connect to MongoDB:", error);
27
+ process.exit(1);
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Gracefully close MongoDB connection
33
+ */
34
+ const disconnectDB = async (): Promise<void> => {
35
+ try {
36
+ await mongoose.connection.close();
37
+ console.log("MongoDB connection closed");
38
+ } catch (error) {
39
+ console.error("Error closing MongoDB connection:", error);
40
+ }
41
+ };
42
+
43
+ export { connectDB, disconnectDB };
@@ -1,48 +1,48 @@
1
- import mongoose, { type Model, Schema } from "mongoose";
2
-
3
- /**
4
- * User document interface
5
- */
6
- export interface IUser {
7
- email: string;
8
- name?: string | null;
9
- password: string;
10
- createdAt: Date;
11
- updatedAt: Date;
12
- }
13
-
14
- /**
15
- * User schema definition
16
- */
17
- const userSchema = new Schema<IUser>(
18
- {
19
- email: {
20
- type: String,
21
- required: true,
22
- unique: true,
23
- lowercase: true,
24
- trim: true,
25
- },
26
- name: {
27
- type: String,
28
- trim: true,
29
- },
30
- password: {
31
- type: String,
32
- required: true,
33
- minlength: 6,
34
- },
35
- },
36
- {
37
- timestamps: true,
38
- }
39
- );
40
-
41
- /**
42
- * User model
43
- */
44
- const User =
45
- (mongoose.models.User as Model<IUser> | undefined) ??
46
- mongoose.model<IUser>("User", userSchema);
47
-
48
- export default User;
1
+ import mongoose, { type Model, Schema } from "mongoose";
2
+
3
+ /**
4
+ * User document interface
5
+ */
6
+ export interface IUser {
7
+ email: string;
8
+ name?: string | null;
9
+ password: string;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ }
13
+
14
+ /**
15
+ * User schema definition
16
+ */
17
+ const userSchema = new Schema<IUser>(
18
+ {
19
+ email: {
20
+ type: String,
21
+ required: true,
22
+ unique: true,
23
+ lowercase: true,
24
+ trim: true,
25
+ },
26
+ name: {
27
+ type: String,
28
+ trim: true,
29
+ },
30
+ password: {
31
+ type: String,
32
+ required: true,
33
+ minlength: 6,
34
+ },
35
+ },
36
+ {
37
+ timestamps: true,
38
+ }
39
+ );
40
+
41
+ /**
42
+ * User model
43
+ */
44
+ const User =
45
+ (mongoose.models.User as Model<IUser> | undefined) ??
46
+ mongoose.model<IUser>("User", userSchema);
47
+
48
+ export default User;
@@ -1,15 +1,16 @@
1
- {
2
- "id": "mongoose",
3
- "name": "Mongoose (MongoDB)",
4
- "description": "MongoDB database integration for NestJS using Mongoose ODM",
5
- "type": "database",
6
- "dependencies": {
7
- "@nestjs/mongoose": "^12.0.0",
8
- "mongoose": "^9.11.4"
9
- },
10
- "devDependencies": {},
11
- "scripts": {},
12
- "envVars": {
13
- "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- }
15
- }
1
+ {
2
+ "id": "mongoose",
3
+ "name": "Mongoose (MongoDB)",
4
+ "description": "MongoDB database integration for NestJS using Mongoose ODM",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "@nestjs/mongoose": "^12.0.0",
8
+ "mongoose": "^9.11.4",
9
+ "mongodb": "^7.8.0"
10
+ },
11
+ "devDependencies": {},
12
+ "scripts": {},
13
+ "envVars": {
14
+ "MONGODB_URI": "mongodb://localhost:27017/myapp"
15
+ }
16
+ }
@@ -1,15 +1,15 @@
1
- {
2
- "id": "mongoose",
3
- "name": "Mongoose (MongoDB)",
4
- "description": "MongoDB database integration for Next.js using Mongoose ODM",
5
- "type": "database",
6
- "dependencies": {
7
- "mongoose": "^9.11.4",
8
- "mongodb": "^7.8.0"
9
- },
10
- "devDependencies": {},
11
- "scripts": {},
12
- "envVars": {
13
- "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- }
15
- }
1
+ {
2
+ "id": "mongoose",
3
+ "name": "Mongoose (MongoDB)",
4
+ "description": "MongoDB database integration for Next.js using Mongoose ODM",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "mongoose": "^9.11.4",
8
+ "mongodb": "^7.8.0"
9
+ },
10
+ "devDependencies": {},
11
+ "scripts": {},
12
+ "envVars": {
13
+ "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
+ }
15
+ }
@@ -1,48 +1,48 @@
1
- import mongoose, { type Model, Schema } from "mongoose";
2
-
3
- /**
4
- * User document interface
5
- */
6
- export interface IUser {
7
- email: string;
8
- name?: string | null;
9
- password: string;
10
- createdAt: Date;
11
- updatedAt: Date;
12
- }
13
-
14
- /**
15
- * User schema definition
16
- */
17
- const userSchema = new Schema<IUser>(
18
- {
19
- email: {
20
- type: String,
21
- required: true,
22
- unique: true,
23
- lowercase: true,
24
- trim: true,
25
- },
26
- name: {
27
- type: String,
28
- trim: true,
29
- },
30
- password: {
31
- type: String,
32
- required: true,
33
- minlength: 6,
34
- },
35
- },
36
- {
37
- timestamps: true,
38
- }
39
- );
40
-
41
- /**
42
- * User model
43
- */
44
- const User =
45
- (mongoose.models.User as Model<IUser> | undefined) ??
46
- mongoose.model<IUser>("User", userSchema);
47
-
48
- export default User;
1
+ import mongoose, { type Model, Schema } from "mongoose";
2
+
3
+ /**
4
+ * User document interface
5
+ */
6
+ export interface IUser {
7
+ email: string;
8
+ name?: string | null;
9
+ password: string;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ }
13
+
14
+ /**
15
+ * User schema definition
16
+ */
17
+ const userSchema = new Schema<IUser>(
18
+ {
19
+ email: {
20
+ type: String,
21
+ required: true,
22
+ unique: true,
23
+ lowercase: true,
24
+ trim: true,
25
+ },
26
+ name: {
27
+ type: String,
28
+ trim: true,
29
+ },
30
+ password: {
31
+ type: String,
32
+ required: true,
33
+ minlength: 6,
34
+ },
35
+ },
36
+ {
37
+ timestamps: true,
38
+ }
39
+ );
40
+
41
+ /**
42
+ * User model
43
+ */
44
+ const User =
45
+ (mongoose.models.User as Model<IUser> | undefined) ??
46
+ mongoose.model<IUser>("User", userSchema);
47
+
48
+ export default User;
@@ -1,16 +1,16 @@
1
- {
2
- "id": "mongoose",
3
- "name": "Mongoose (MongoDB)",
4
- "description": "MongoDB database integration for TanStack Start using Mongoose ODM",
5
- "type": "database",
6
- "dependencies": {
7
- "mongoose": "^9.11.4",
8
- "mongodb": "^7.8.0",
9
- "dotenv": "^17.4.2"
10
- },
11
- "devDependencies": {},
12
- "scripts": {},
13
- "envVars": {
14
- "MONGODB_URI": "mongodb://localhost:27017/myapp"
15
- }
16
- }
1
+ {
2
+ "id": "mongoose",
3
+ "name": "Mongoose (MongoDB)",
4
+ "description": "MongoDB database integration for TanStack Start using Mongoose ODM",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "mongoose": "^9.11.4",
8
+ "mongodb": "^7.8.0",
9
+ "dotenv": "^17.4.2"
10
+ },
11
+ "devDependencies": {},
12
+ "scripts": {},
13
+ "envVars": {
14
+ "MONGODB_URI": "mongodb://localhost:27017/myapp"
15
+ }
16
+ }
@@ -1,48 +1,48 @@
1
- import mongoose, { type Model, Schema } from "mongoose";
2
-
3
- /**
4
- * User document interface
5
- */
6
- export interface IUser {
7
- email: string;
8
- name?: string | null;
9
- password: string;
10
- createdAt: Date;
11
- updatedAt: Date;
12
- }
13
-
14
- /**
15
- * User schema definition
16
- */
17
- const userSchema = new Schema<IUser>(
18
- {
19
- email: {
20
- type: String,
21
- required: true,
22
- unique: true,
23
- lowercase: true,
24
- trim: true,
25
- },
26
- name: {
27
- type: String,
28
- trim: true,
29
- },
30
- password: {
31
- type: String,
32
- required: true,
33
- minlength: 6,
34
- },
35
- },
36
- {
37
- timestamps: true,
38
- }
39
- );
40
-
41
- /**
42
- * User model
43
- */
44
- const User =
45
- (mongoose.models.User as Model<IUser> | undefined) ??
46
- mongoose.model<IUser>("User", userSchema);
47
-
48
- export default User;
1
+ import mongoose, { type Model, Schema } from "mongoose";
2
+
3
+ /**
4
+ * User document interface
5
+ */
6
+ export interface IUser {
7
+ email: string;
8
+ name?: string | null;
9
+ password: string;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ }
13
+
14
+ /**
15
+ * User schema definition
16
+ */
17
+ const userSchema = new Schema<IUser>(
18
+ {
19
+ email: {
20
+ type: String,
21
+ required: true,
22
+ unique: true,
23
+ lowercase: true,
24
+ trim: true,
25
+ },
26
+ name: {
27
+ type: String,
28
+ trim: true,
29
+ },
30
+ password: {
31
+ type: String,
32
+ required: true,
33
+ minlength: 6,
34
+ },
35
+ },
36
+ {
37
+ timestamps: true,
38
+ }
39
+ );
40
+
41
+ /**
42
+ * User model
43
+ */
44
+ const User =
45
+ (mongoose.models.User as Model<IUser> | undefined) ??
46
+ mongoose.model<IUser>("User", userSchema);
47
+
48
+ export default User;
@@ -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.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
+ {
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
+ }
@@ -0,0 +1,92 @@
1
+ // Prisma schema file
2
+ // Learn more: https://pris.ly/d/prisma-schema
3
+
4
+ generator client {
5
+ provider = "prisma-client"
6
+ moduleFormat = "cjs"
7
+ output = "../src/generated/prisma"
8
+ }
9
+
10
+ datasource db {
11
+ provider = "postgresql"
12
+ }
13
+
14
+ {{#if useAuth}}
15
+ // Better Auth tables
16
+ model User {
17
+ id String @id
18
+ name String
19
+ email String
20
+ emailVerified Boolean @default(false)
21
+ image String?
22
+ createdAt DateTime @default(now())
23
+ updatedAt DateTime @updatedAt
24
+ sessions Session[]
25
+ accounts Account[]
26
+
27
+ @@unique([email])
28
+ @@map("user")
29
+ }
30
+
31
+ model Session {
32
+ id String @id
33
+ expiresAt DateTime
34
+ token String
35
+ createdAt DateTime @default(now())
36
+ updatedAt DateTime @updatedAt
37
+ ipAddress String?
38
+ userAgent String?
39
+ userId String
40
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
41
+
42
+ @@unique([token])
43
+ @@index([userId])
44
+ @@map("session")
45
+ }
46
+
47
+ model Account {
48
+ id String @id
49
+ accountId String
50
+ providerId String
51
+ userId String
52
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
53
+ accessToken String?
54
+ refreshToken String?
55
+ idToken String?
56
+ accessTokenExpiresAt DateTime?
57
+ refreshTokenExpiresAt DateTime?
58
+ scope String?
59
+ password String?
60
+ createdAt DateTime @default(now())
61
+ updatedAt DateTime @updatedAt
62
+
63
+ @@index([userId])
64
+ @@unique([providerId, accountId])
65
+ @@map("account")
66
+ }
67
+
68
+ model Verification {
69
+ id String @id
70
+ identifier String
71
+ value String
72
+ expiresAt DateTime
73
+ createdAt DateTime @default(now())
74
+ updatedAt DateTime @updatedAt
75
+
76
+ @@index([identifier])
77
+ @@map("verification")
78
+ }
79
+
80
+ {{else}}
81
+ // Sample User model
82
+ model User {
83
+ id String @id @default(uuid())
84
+ email String @unique
85
+ name String?
86
+ password String
87
+ createdAt DateTime @default(now())
88
+ updatedAt DateTime @updatedAt
89
+
90
+ @@map("users")
91
+ }
92
+ {{/if}}