better-ts-stack 0.1.1 → 1.1.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 (118) hide show
  1. package/README.md +12 -6
  2. package/dist/builder/configGenerator.d.ts.map +1 -1
  3. package/dist/builder/configGenerator.js +30 -24
  4. package/dist/builder/configGenerator.js.map +1 -1
  5. package/dist/builder/dependencyInstaller.d.ts.map +1 -1
  6. package/dist/builder/dependencyInstaller.js +1 -10
  7. package/dist/builder/dependencyInstaller.js.map +1 -1
  8. package/dist/builder/index.d.ts.map +1 -1
  9. package/dist/builder/index.js +3 -7
  10. package/dist/builder/index.js.map +1 -1
  11. package/dist/builder/moduleSelector.d.ts.map +1 -1
  12. package/dist/builder/moduleSelector.js +1 -1
  13. package/dist/builder/moduleSelector.js.map +1 -1
  14. package/dist/builder/templateContext.d.ts +2 -2
  15. package/dist/builder/templateContext.d.ts.map +1 -1
  16. package/dist/builder/templateContext.js +1 -3
  17. package/dist/builder/templateContext.js.map +1 -1
  18. package/dist/modules/registry.d.ts.map +1 -1
  19. package/dist/modules/registry.js +2 -5
  20. package/dist/modules/registry.js.map +1 -1
  21. package/dist/output/nextSteps.d.ts.map +1 -1
  22. package/dist/output/nextSteps.js +7 -34
  23. package/dist/output/nextSteps.js.map +1 -1
  24. package/dist/prompts/index.d.ts.map +1 -1
  25. package/dist/prompts/index.js +3 -14
  26. package/dist/prompts/index.js.map +1 -1
  27. package/dist/prompts/stack.d.ts +3 -0
  28. package/dist/prompts/stack.d.ts.map +1 -0
  29. package/dist/prompts/stack.js +77 -0
  30. package/dist/prompts/stack.js.map +1 -0
  31. package/dist/types/index.d.ts +12 -10
  32. package/dist/types/index.d.ts.map +1 -1
  33. package/dist/types/index.js +6 -10
  34. package/dist/types/index.js.map +1 -1
  35. package/dist/validators/index.d.ts +1 -1
  36. package/dist/validators/index.d.ts.map +1 -1
  37. package/dist/validators/index.js +1 -1
  38. package/package.json +12 -12
  39. package/templates/backend/express/config.json +44 -42
  40. package/templates/backend/express/eslint.config.mjs +40 -31
  41. package/templates/backend/express/src/index.ts +61 -46
  42. package/templates/backend/express/src/routes/health.ts +12 -12
  43. package/templates/backend/express/tsconfig.json +25 -23
  44. package/templates/frontend/nextjs/config.json +33 -27
  45. package/templates/frontend/nextjs/eslint.config.mjs +11 -11
  46. package/templates/frontend/nextjs/proxy.ts.hbs +9 -8
  47. package/templates/frontend/nextjs/tsconfig.json +34 -21
  48. package/templates/frontend/tanstack/components.json +18 -0
  49. package/templates/frontend/tanstack/config.json +49 -0
  50. package/templates/frontend/tanstack/eslint.config.mjs +23 -0
  51. package/templates/frontend/tanstack/gitignore +38 -0
  52. package/templates/frontend/tanstack/public/favicon.svg +7 -0
  53. package/templates/frontend/tanstack/src/components/ui/button.tsx +51 -0
  54. package/templates/frontend/tanstack/src/components/ui/card.tsx +60 -0
  55. package/templates/frontend/tanstack/src/components/ui/field.tsx +67 -0
  56. package/templates/frontend/tanstack/src/components/ui/input.tsx +18 -0
  57. package/templates/frontend/tanstack/src/lib/utils.ts +6 -0
  58. package/templates/frontend/tanstack/src/routeTree.gen.ts +68 -0
  59. package/templates/frontend/tanstack/src/router.tsx +32 -0
  60. package/templates/frontend/tanstack/src/routes/__root.tsx +70 -0
  61. package/templates/frontend/tanstack/src/routes/index.tsx.hbs +102 -0
  62. package/templates/frontend/tanstack/src/styles/app.css +85 -0
  63. package/templates/frontend/tanstack/tsconfig.json +22 -0
  64. package/templates/frontend/tanstack/vite.config.ts +14 -0
  65. package/templates/modules/auth/express/config.json +26 -1
  66. package/templates/modules/auth/express/src/routes/auth.ts.hbs +1 -1
  67. package/templates/modules/auth/express/src/services/userStore.ts.hbs +95 -107
  68. package/templates/modules/auth/nextjs/config.json +6 -6
  69. package/templates/modules/auth/nextjs/lib/auth.ts.hbs +34 -32
  70. package/templates/modules/auth/tanstack/config.json +33 -0
  71. package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +135 -0
  72. package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +49 -0
  73. package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +153 -0
  74. package/templates/modules/auth/tanstack/src/lib/auth-client.ts +3 -0
  75. package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +12 -0
  76. package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +39 -0
  77. package/templates/modules/auth/tanstack/src/lib/auth.ts.hbs +38 -0
  78. package/templates/modules/auth/tanstack/src/routeTree.gen.ts +140 -0
  79. package/templates/modules/auth/tanstack/src/routes/api/auth/$.ts +16 -0
  80. package/templates/modules/auth/tanstack/src/routes/dashboard.tsx +111 -0
  81. package/templates/modules/auth/tanstack/src/routes/sign-in.tsx +37 -0
  82. package/templates/modules/auth/tanstack/src/routes/sign-up.tsx +37 -0
  83. package/templates/modules/docker/.dockerignore +14 -13
  84. package/templates/modules/docker/Dockerfile.hbs +64 -9
  85. package/templates/modules/docker/config.json +19 -16
  86. package/templates/modules/docker/docker-compose.yml.hbs +9 -9
  87. package/templates/modules/drizzle/express/config.json +27 -0
  88. package/templates/modules/drizzle/express/drizzle.config.ts +13 -0
  89. package/templates/modules/drizzle/express/src/lib/db.ts +13 -0
  90. package/templates/modules/drizzle/express/src/lib/schema.ts +10 -0
  91. package/templates/modules/drizzle/nextjs/config.json +27 -19
  92. package/templates/modules/drizzle/nextjs/lib/db.ts +3 -1
  93. package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +84 -84
  94. package/templates/modules/drizzle/tanstack/config.json +26 -0
  95. package/templates/modules/drizzle/tanstack/drizzle.config.ts +13 -0
  96. package/templates/modules/drizzle/tanstack/src/lib/db.ts +13 -0
  97. package/templates/modules/drizzle/tanstack/src/lib/schema.ts.hbs +84 -0
  98. package/templates/modules/mongoose/config.json +16 -16
  99. package/templates/modules/mongoose/src/lib/db.ts.hbs +0 -13
  100. package/templates/modules/mongoose/src/models/User.ts +48 -47
  101. package/templates/modules/prisma/express/config.json +27 -21
  102. package/templates/modules/prisma/express/prisma/schema.prisma +3 -2
  103. package/templates/modules/prisma/express/prisma.config.ts +12 -13
  104. package/templates/modules/prisma/express/src/lib/prisma.ts +24 -37
  105. package/templates/modules/prisma/nextjs/config.json +28 -23
  106. package/templates/modules/prisma/nextjs/prisma/schema.prisma.hbs +91 -90
  107. package/templates/modules/prisma/tanstack/config.json +28 -0
  108. package/templates/modules/prisma/tanstack/prisma/schema.prisma.hbs +91 -0
  109. package/templates/modules/prisma/tanstack/prisma.config.ts +12 -0
  110. package/templates/modules/prisma/tanstack/src/lib/prisma.ts +18 -0
  111. package/dist/prompts/backend/index.d.ts +0 -3
  112. package/dist/prompts/backend/index.d.ts.map +0 -1
  113. package/dist/prompts/backend/index.js +0 -128
  114. package/dist/prompts/backend/index.js.map +0 -1
  115. package/dist/prompts/frontend/index.d.ts +0 -3
  116. package/dist/prompts/frontend/index.d.ts.map +0 -1
  117. package/dist/prompts/frontend/index.js +0 -111
  118. package/dist/prompts/frontend/index.js.map +0 -1
@@ -1,84 +1,84 @@
1
- {{#if useAuth}}
2
- import { boolean, pgTable, text, timestamp } 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
- });
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
+ });
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}}
@@ -0,0 +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.2",
8
+ "pg": "^8.23.0",
9
+ "dotenv": "^17.4.2"
10
+ },
11
+ "devDependencies": {
12
+ "drizzle-kit": "^0.31.10",
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://user:password@localhost:5432/mydb?schema=public"
22
+ },
23
+ "templateFiles": [
24
+ "src/lib/schema.ts.hbs"
25
+ ]
26
+ }
@@ -0,0 +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
+ },
13
+ });
@@ -0,0 +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 });
@@ -0,0 +1,84 @@
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,16 +1,16 @@
1
- {
2
- "id": "mongoose",
3
- "name": "Mongoose (MongoDB)",
4
- "description": "MongoDB database integration using Mongoose ODM",
5
- "type": "database",
6
- "dependencies": {
7
- "mongoose": "^8.0.0",
8
- "mongodb": "^6.0.0"
9
- },
10
- "devDependencies": {},
11
- "scripts": {},
12
- "envVars": {
13
- "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
- },
15
- "templateFiles": ["src/lib/db.ts.hbs"]
16
- }
1
+ {
2
+ "id": "mongoose",
3
+ "name": "Mongoose (MongoDB)",
4
+ "description": "MongoDB database integration using Mongoose ODM",
5
+ "type": "database",
6
+ "dependencies": {
7
+ "mongoose": "^9.9.5",
8
+ "mongodb": "^7.6.0"
9
+ },
10
+ "devDependencies": {},
11
+ "scripts": {},
12
+ "envVars": {
13
+ "MONGODB_URI": "mongodb://localhost:27017/myapp"
14
+ },
15
+ "templateFiles": ["src/lib/db.ts.hbs"]
16
+ }
@@ -1,15 +1,3 @@
1
- {{#if useAuth}}
2
- import { MongoClient } from "mongodb";
3
-
4
- const uri = process.env.MONGODB_URI;
5
-
6
- if (!uri) {
7
- throw new Error("MONGODB_URI environment variable is not defined");
8
- }
9
-
10
- export const client = new MongoClient(uri);
11
- export const db = client.db();
12
- {{else}}
13
1
  import mongoose from "mongoose";
14
2
 
15
3
  /**
@@ -53,4 +41,3 @@ const disconnectDB = async (): Promise<void> => {
53
41
  };
54
42
 
55
43
  export { connectDB, disconnectDB };
56
- {{/if}}
@@ -1,47 +1,48 @@
1
- import mongoose, { Document, Schema } from "mongoose";
2
-
3
- /**
4
- * User document interface
5
- */
6
- export interface IUser extends Document {
7
- email: string;
8
- name: string;
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
- required: true,
29
- trim: true,
30
- },
31
- password: {
32
- type: String,
33
- required: true,
34
- minlength: 6,
35
- },
36
- },
37
- {
38
- timestamps: true,
39
- }
40
- );
41
-
42
- /**
43
- * User model
44
- */
45
- const User = mongoose.model<IUser>("User", userSchema);
46
-
47
- 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,21 +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.4.1",
8
- "@prisma/client": "^7.4.1"
9
- },
10
- "devDependencies": { "prisma": "^7.4.1" },
11
- "scripts": {
12
- "prisma:generate": "prisma generate",
13
- "prisma:migrate": "prisma migrate dev",
14
- "prisma:studio": "prisma studio",
15
- "prisma:seed": "{{#if (eq packageManager 'bun')}}bun prisma/seed.ts{{else}}tsx prisma/seed.ts{{/if}}"
16
- },
17
- "envVars": {
18
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
19
- },
20
- "templateFiles": []
21
- }
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
+ "prebuild": "prisma generate"
18
+ },
19
+ "envVars": {
20
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
21
+ },
22
+ "templateFiles": [],
23
+ "overrides": {
24
+ "deepmerge-ts": "^8.0.2",
25
+ "mysql2": "^3.24.3"
26
+ }
27
+ }
@@ -2,8 +2,9 @@
2
2
  // Learn more: https://pris.ly/d/prisma-schema
3
3
 
4
4
  generator client {
5
- provider = "prisma-client-js"
6
- output = "../app/generated/prisma"
5
+ provider = "prisma-client"
6
+ moduleFormat = "cjs"
7
+ output = "../src/generated/prisma"
7
8
  }
8
9
 
9
10
  datasource db {
@@ -1,13 +1,12 @@
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
- seed: "tsx prisma/seed.ts",
9
- },
10
- datasource: {
11
- url: env("DATABASE_URL"),
12
- },
13
- });
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,37 +1,24 @@
1
- /**
2
- * Prisma Client Setup
3
- * Uses PrismaPg driver adapter for PostgreSQL. Singleton in development to avoid multiple connections.
4
- * @see https://www.prisma.io/docs/orm/overview/databases/postgresql#pg-and-prismapg
5
- */
6
- import "dotenv/config";
7
- import { PrismaPg } from "@prisma/adapter-pg";
8
- import { PrismaClient } from "../../app/generated/prisma";
9
-
10
- const pool = new PrismaPg({
11
- connectionString: process.env.DATABASE_URL!,
12
- });
13
- const prismaClient = new PrismaClient({
14
- adapter: pool,
15
- log:
16
- process.env.NODE_ENV === "development"
17
- ? ["query", "error", "warn"]
18
- : ["error"],
19
- });
20
-
21
- const globalForPrisma = globalThis as unknown as {
22
- prisma: PrismaClient | undefined;
23
- };
24
-
25
- export const prisma =
26
- globalForPrisma.prisma ?? prismaClient;
27
-
28
- if (process.env.NODE_ENV !== "production") {
29
- globalForPrisma.prisma = prisma;
30
- }
31
-
32
- /**
33
- * Gracefully disconnect Prisma on application shutdown
34
- */
35
- export async function disconnectPrisma(): Promise<void> {
36
- await prisma.$disconnect();
37
- }
1
+ import { PrismaPg } from "@prisma/adapter-pg";
2
+ import "dotenv/config";
3
+
4
+ import { PrismaClient } from "../generated/prisma/client";
5
+
6
+ const globalForPrisma = globalThis as unknown as {
7
+ prisma: PrismaClient | undefined;
8
+ };
9
+
10
+ export const prisma =
11
+ globalForPrisma.prisma ??
12
+ new PrismaClient({
13
+ adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }),
14
+ log:
15
+ process.env.NODE_ENV === "development"
16
+ ? ["query", "error", "warn"]
17
+ : ["error"],
18
+ });
19
+
20
+ if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
21
+
22
+ export async function disconnectPrisma(): Promise<void> {
23
+ await prisma.$disconnect();
24
+ }
@@ -1,23 +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.4.1",
8
- "@prisma/adapter-pg": "^7.4.1"
9
- },
10
- "devDependencies": {
11
- "prisma": "^7.4.1",
12
- "dotenv": "^17.3.1"
13
- },
14
- "scripts": {
15
- "prisma:generate": "prisma generate",
16
- "prisma:migrate": "prisma migrate dev",
17
- "prisma:studio": "prisma studio"
18
- },
19
- "envVars": {
20
- "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
21
- },
22
- "templateFiles": ["prisma/schema.prisma.hbs"]
23
- }
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
+ "prebuild": "prisma generate"
19
+ },
20
+ "envVars": {
21
+ "DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public"
22
+ },
23
+ "templateFiles": ["prisma/schema.prisma.hbs"],
24
+ "overrides": {
25
+ "deepmerge-ts": "^8.0.2",
26
+ "mysql2": "^3.24.3"
27
+ }
28
+ }