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.
- package/README.md +12 -6
- package/dist/builder/configGenerator.d.ts.map +1 -1
- package/dist/builder/configGenerator.js +30 -24
- package/dist/builder/configGenerator.js.map +1 -1
- package/dist/builder/dependencyInstaller.d.ts.map +1 -1
- package/dist/builder/dependencyInstaller.js +1 -10
- package/dist/builder/dependencyInstaller.js.map +1 -1
- package/dist/builder/index.d.ts.map +1 -1
- package/dist/builder/index.js +3 -7
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/moduleSelector.d.ts.map +1 -1
- package/dist/builder/moduleSelector.js +1 -1
- package/dist/builder/moduleSelector.js.map +1 -1
- package/dist/builder/templateContext.d.ts +2 -2
- package/dist/builder/templateContext.d.ts.map +1 -1
- package/dist/builder/templateContext.js +1 -3
- package/dist/builder/templateContext.js.map +1 -1
- package/dist/modules/registry.d.ts.map +1 -1
- package/dist/modules/registry.js +2 -5
- package/dist/modules/registry.js.map +1 -1
- package/dist/output/nextSteps.d.ts.map +1 -1
- package/dist/output/nextSteps.js +7 -34
- package/dist/output/nextSteps.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -14
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/stack.d.ts +3 -0
- package/dist/prompts/stack.d.ts.map +1 -0
- package/dist/prompts/stack.js +77 -0
- package/dist/prompts/stack.js.map +1 -0
- package/dist/types/index.d.ts +12 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -10
- package/dist/types/index.js.map +1 -1
- package/dist/validators/index.d.ts +1 -1
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js +1 -1
- package/package.json +12 -12
- package/templates/backend/express/config.json +44 -42
- package/templates/backend/express/eslint.config.mjs +40 -31
- package/templates/backend/express/src/index.ts +61 -46
- package/templates/backend/express/src/routes/health.ts +12 -12
- package/templates/backend/express/tsconfig.json +25 -23
- package/templates/frontend/nextjs/config.json +33 -27
- package/templates/frontend/nextjs/eslint.config.mjs +11 -11
- package/templates/frontend/nextjs/proxy.ts.hbs +9 -8
- package/templates/frontend/nextjs/tsconfig.json +34 -21
- package/templates/frontend/tanstack/components.json +18 -0
- package/templates/frontend/tanstack/config.json +49 -0
- package/templates/frontend/tanstack/eslint.config.mjs +23 -0
- package/templates/frontend/tanstack/gitignore +38 -0
- package/templates/frontend/tanstack/public/favicon.svg +7 -0
- package/templates/frontend/tanstack/src/components/ui/button.tsx +51 -0
- package/templates/frontend/tanstack/src/components/ui/card.tsx +60 -0
- package/templates/frontend/tanstack/src/components/ui/field.tsx +67 -0
- package/templates/frontend/tanstack/src/components/ui/input.tsx +18 -0
- package/templates/frontend/tanstack/src/lib/utils.ts +6 -0
- package/templates/frontend/tanstack/src/routeTree.gen.ts +68 -0
- package/templates/frontend/tanstack/src/router.tsx +32 -0
- package/templates/frontend/tanstack/src/routes/__root.tsx +70 -0
- package/templates/frontend/tanstack/src/routes/index.tsx.hbs +102 -0
- package/templates/frontend/tanstack/src/styles/app.css +85 -0
- package/templates/frontend/tanstack/tsconfig.json +22 -0
- package/templates/frontend/tanstack/vite.config.ts +14 -0
- package/templates/modules/auth/express/config.json +26 -1
- package/templates/modules/auth/express/src/routes/auth.ts.hbs +1 -1
- package/templates/modules/auth/express/src/services/userStore.ts.hbs +95 -107
- package/templates/modules/auth/nextjs/config.json +6 -6
- package/templates/modules/auth/nextjs/lib/auth.ts.hbs +34 -32
- package/templates/modules/auth/tanstack/config.json +33 -0
- package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +135 -0
- package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +49 -0
- package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +153 -0
- package/templates/modules/auth/tanstack/src/lib/auth-client.ts +3 -0
- package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +12 -0
- package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +39 -0
- package/templates/modules/auth/tanstack/src/lib/auth.ts.hbs +38 -0
- package/templates/modules/auth/tanstack/src/routeTree.gen.ts +140 -0
- package/templates/modules/auth/tanstack/src/routes/api/auth/$.ts +16 -0
- package/templates/modules/auth/tanstack/src/routes/dashboard.tsx +111 -0
- package/templates/modules/auth/tanstack/src/routes/sign-in.tsx +37 -0
- package/templates/modules/auth/tanstack/src/routes/sign-up.tsx +37 -0
- package/templates/modules/docker/.dockerignore +14 -13
- package/templates/modules/docker/Dockerfile.hbs +64 -9
- package/templates/modules/docker/config.json +19 -16
- package/templates/modules/docker/docker-compose.yml.hbs +9 -9
- package/templates/modules/drizzle/express/config.json +27 -0
- package/templates/modules/drizzle/express/drizzle.config.ts +13 -0
- package/templates/modules/drizzle/express/src/lib/db.ts +13 -0
- package/templates/modules/drizzle/express/src/lib/schema.ts +10 -0
- package/templates/modules/drizzle/nextjs/config.json +27 -19
- package/templates/modules/drizzle/nextjs/lib/db.ts +3 -1
- package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +84 -84
- package/templates/modules/drizzle/tanstack/config.json +26 -0
- package/templates/modules/drizzle/tanstack/drizzle.config.ts +13 -0
- package/templates/modules/drizzle/tanstack/src/lib/db.ts +13 -0
- package/templates/modules/drizzle/tanstack/src/lib/schema.ts.hbs +84 -0
- package/templates/modules/mongoose/config.json +16 -16
- package/templates/modules/mongoose/src/lib/db.ts.hbs +0 -13
- package/templates/modules/mongoose/src/models/User.ts +48 -47
- package/templates/modules/prisma/express/config.json +27 -21
- package/templates/modules/prisma/express/prisma/schema.prisma +3 -2
- package/templates/modules/prisma/express/prisma.config.ts +12 -13
- package/templates/modules/prisma/express/src/lib/prisma.ts +24 -37
- package/templates/modules/prisma/nextjs/config.json +28 -23
- package/templates/modules/prisma/nextjs/prisma/schema.prisma.hbs +91 -90
- package/templates/modules/prisma/tanstack/config.json +28 -0
- package/templates/modules/prisma/tanstack/prisma/schema.prisma.hbs +91 -0
- package/templates/modules/prisma/tanstack/prisma.config.ts +12 -0
- package/templates/modules/prisma/tanstack/src/lib/prisma.ts +18 -0
- package/dist/prompts/backend/index.d.ts +0 -3
- package/dist/prompts/backend/index.d.ts.map +0 -1
- package/dist/prompts/backend/index.js +0 -128
- package/dist/prompts/backend/index.js.map +0 -1
- package/dist/prompts/frontend/index.d.ts +0 -3
- package/dist/prompts/frontend/index.d.ts.map +0 -1
- package/dist/prompts/frontend/index.js +0 -111
- 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
|
-
"mongodb": "^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
|
+
{
|
|
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, {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* User document interface
|
|
5
|
-
*/
|
|
6
|
-
export interface IUser
|
|
7
|
-
email: string;
|
|
8
|
-
name
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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.
|
|
8
|
-
"@prisma/client": "^7.
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"prisma:
|
|
15
|
-
"prisma:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
}
|
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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.
|
|
8
|
-
"@prisma/adapter-pg": "^7.
|
|
9
|
-
},
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"prisma": "^7.
|
|
12
|
-
"dotenv": "^17.
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"prisma:generate": "prisma generate",
|
|
16
|
-
"prisma:migrate": "prisma migrate dev",
|
|
17
|
-
"prisma:studio": "prisma studio"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
}
|