better-ts-stack 0.1.1 → 1.0.8

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 (77) hide show
  1. package/README.md +12 -6
  2. package/dist/builder/configGenerator.d.ts.map +1 -1
  3. package/dist/builder/configGenerator.js +26 -23
  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/templateContext.d.ts +1 -1
  12. package/dist/builder/templateContext.d.ts.map +1 -1
  13. package/dist/builder/templateContext.js +0 -2
  14. package/dist/builder/templateContext.js.map +1 -1
  15. package/dist/modules/registry.d.ts.map +1 -1
  16. package/dist/modules/registry.js +2 -5
  17. package/dist/modules/registry.js.map +1 -1
  18. package/dist/output/nextSteps.d.ts.map +1 -1
  19. package/dist/output/nextSteps.js +7 -34
  20. package/dist/output/nextSteps.js.map +1 -1
  21. package/dist/prompts/index.d.ts.map +1 -1
  22. package/dist/prompts/index.js +3 -14
  23. package/dist/prompts/index.js.map +1 -1
  24. package/dist/prompts/stack.d.ts +3 -0
  25. package/dist/prompts/stack.d.ts.map +1 -0
  26. package/dist/prompts/stack.js +72 -0
  27. package/dist/prompts/stack.js.map +1 -0
  28. package/dist/types/index.d.ts +4 -7
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/dist/types/index.js +0 -9
  31. package/dist/types/index.js.map +1 -1
  32. package/dist/validators/index.d.ts +1 -1
  33. package/dist/validators/index.d.ts.map +1 -1
  34. package/dist/validators/index.js +1 -1
  35. package/package.json +12 -12
  36. package/templates/backend/express/config.json +44 -42
  37. package/templates/backend/express/eslint.config.mjs +40 -31
  38. package/templates/backend/express/src/index.ts +61 -46
  39. package/templates/backend/express/src/routes/health.ts +12 -12
  40. package/templates/backend/express/tsconfig.json +25 -23
  41. package/templates/frontend/nextjs/config.json +33 -27
  42. package/templates/frontend/nextjs/eslint.config.mjs +11 -11
  43. package/templates/frontend/nextjs/proxy.ts.hbs +9 -8
  44. package/templates/frontend/nextjs/tsconfig.json +34 -21
  45. package/templates/modules/auth/express/config.json +26 -1
  46. package/templates/modules/auth/express/src/routes/auth.ts.hbs +1 -1
  47. package/templates/modules/auth/express/src/services/userStore.ts.hbs +95 -107
  48. package/templates/modules/auth/nextjs/config.json +6 -6
  49. package/templates/modules/auth/nextjs/lib/auth.ts.hbs +34 -32
  50. package/templates/modules/docker/.dockerignore +14 -13
  51. package/templates/modules/docker/Dockerfile.hbs +80 -70
  52. package/templates/modules/docker/config.json +19 -16
  53. package/templates/modules/docker/docker-compose.yml.hbs +9 -9
  54. package/templates/modules/drizzle/express/config.json +27 -0
  55. package/templates/modules/drizzle/express/drizzle.config.ts +13 -0
  56. package/templates/modules/drizzle/express/src/lib/db.ts +13 -0
  57. package/templates/modules/drizzle/express/src/lib/schema.ts +10 -0
  58. package/templates/modules/drizzle/nextjs/config.json +27 -19
  59. package/templates/modules/drizzle/nextjs/lib/db.ts +3 -1
  60. package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +84 -84
  61. package/templates/modules/mongoose/config.json +16 -16
  62. package/templates/modules/mongoose/src/lib/db.ts.hbs +0 -13
  63. package/templates/modules/mongoose/src/models/User.ts +48 -47
  64. package/templates/modules/prisma/express/config.json +27 -21
  65. package/templates/modules/prisma/express/prisma/schema.prisma +3 -2
  66. package/templates/modules/prisma/express/prisma.config.ts +12 -13
  67. package/templates/modules/prisma/express/src/lib/prisma.ts +24 -37
  68. package/templates/modules/prisma/nextjs/config.json +28 -23
  69. package/templates/modules/prisma/nextjs/prisma/schema.prisma.hbs +91 -90
  70. package/dist/prompts/backend/index.d.ts +0 -3
  71. package/dist/prompts/backend/index.d.ts.map +0 -1
  72. package/dist/prompts/backend/index.js +0 -128
  73. package/dist/prompts/backend/index.js.map +0 -1
  74. package/dist/prompts/frontend/index.d.ts +0 -3
  75. package/dist/prompts/frontend/index.d.ts.map +0 -1
  76. package/dist/prompts/frontend/index.js +0 -111
  77. package/dist/prompts/frontend/index.js.map +0 -1
@@ -0,0 +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: "./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,10 @@
1
+ import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
2
+
3
+ export const users = pgTable("users", {
4
+ id: uuid("id").primaryKey().defaultRandom(),
5
+ email: text("email").notNull().unique(),
6
+ name: text("name"),
7
+ password: text("password").notNull(),
8
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
9
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
10
+ });
@@ -1,21 +1,29 @@
1
- {
2
- "id": "drizzle",
3
- "name": "Drizzle ORM",
4
- "description": "Drizzle ORM for Next.js with PostgreSQL",
5
- "type": "database",
1
+ {
2
+ "id": "drizzle",
3
+ "name": "Drizzle ORM",
4
+ "description": "Drizzle ORM for Next.js with PostgreSQL",
5
+ "type": "database",
6
6
  "dependencies": {
7
- "drizzle-orm": "^0.41.0",
8
- "pg": "^8.13.0",
9
- "dotenv": "^17.3.1"
7
+ "drizzle-orm": "^0.45.2",
8
+ "pg": "^8.23.0",
9
+ "dotenv": "^17.4.2"
10
10
  },
11
- "devDependencies": { "drizzle-kit": "^0.31.4", "@types/pg": "^8.11.0" },
12
- "scripts": {
13
- "db:generate": "drizzle-kit generate",
14
- "db:migrate": "drizzle-kit migrate",
15
- "db:studio": "drizzle-kit studio"
16
- },
17
- "envVars": {
18
- "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb?schema=public"
19
- },
20
- "templateFiles": ["lib/schema.ts.hbs"]
21
- }
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
+ "lib/schema.ts.hbs"
25
+ ],
26
+ "overrides": {
27
+ "esbuild": "^0.28.2"
28
+ }
29
+ }
@@ -2,10 +2,12 @@ import { config } from "dotenv";
2
2
  import { drizzle } from "drizzle-orm/node-postgres";
3
3
  import { Pool } from "pg";
4
4
 
5
+ import * as schema from "./schema";
6
+
5
7
  config({ path: ".env" }); // or .env.local
6
8
 
7
9
  const pool = new Pool({
8
10
  connectionString: process.env.DATABASE_URL,
9
11
  });
10
12
 
11
- export const db = drizzle(pool);
13
+ export const db = drizzle(pool, { schema });
@@ -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}}
@@ -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
+ }