create-stackkit-app 0.4.5 → 0.4.6
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/dist/index.js +1 -2
- package/dist/lib/code-generator.d.ts +80 -0
- package/dist/lib/code-generator.js +541 -0
- package/dist/lib/create-project.js +57 -84
- package/dist/lib/framework-utils.d.ts +22 -0
- package/dist/lib/framework-utils.js +74 -0
- package/dist/lib/utils/module-discovery.d.ts +62 -0
- package/dist/lib/utils/module-discovery.js +180 -0
- package/modules/auth/authjs/files/lib/auth.ts +0 -5
- package/modules/auth/authjs/module.json +6 -79
- package/modules/auth/better-auth/files/lib/auth.ts +17 -3
- package/modules/auth/better-auth/files/schemas/prisma-schema.prisma +6 -6
- package/modules/auth/better-auth/generator.json +83 -0
- package/modules/auth/better-auth/module.json +6 -160
- package/modules/database/mongoose/files/lib/db.ts +2 -7
- package/modules/database/mongoose/generator.json +33 -0
- package/modules/database/mongoose/module.json +6 -46
- package/modules/database/prisma/files/lib/prisma.ts +9 -4
- package/modules/database/prisma/generator.json +46 -0
- package/modules/database/prisma/module.json +6 -114
- package/package.json +1 -1
- package/templates/express/template.json +6 -19
- package/templates/nextjs/template.json +5 -1
- package/templates/react-vite/template.json +6 -14
- package/dist/lib/utils/config-utils.d.ts +0 -2
- package/dist/lib/utils/config-utils.js +0 -88
- package/dist/lib/utils/file-utils.d.ts +0 -8
- package/dist/lib/utils/file-utils.js +0 -75
- package/dist/lib/utils/module-utils.d.ts +0 -2
- package/dist/lib/utils/module-utils.js +0 -461
|
@@ -5,91 +5,18 @@
|
|
|
5
5
|
"category": "auth",
|
|
6
6
|
"provider": "authjs",
|
|
7
7
|
"supportedFrameworks": ["nextjs"],
|
|
8
|
+
"compatibility": {
|
|
9
|
+
"frameworks": ["nextjs"],
|
|
10
|
+
"databases": ["prisma"],
|
|
11
|
+
"languages": ["typescript", "javascript"],
|
|
12
|
+
"packageManagers": ["npm", "yarn", "pnpm", "bun"]
|
|
13
|
+
},
|
|
8
14
|
"databaseAdapters": {
|
|
9
15
|
"common": {
|
|
10
16
|
"dependencies": {
|
|
11
17
|
"@auth/prisma-adapter": "^2.7.1"
|
|
12
18
|
},
|
|
13
19
|
"devDependencies": {}
|
|
14
|
-
},
|
|
15
|
-
"prisma-postgresql": {
|
|
16
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
17
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
18
|
-
"dependencies": {}
|
|
19
|
-
},
|
|
20
|
-
"prisma-mongodb": {
|
|
21
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
22
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
23
|
-
"dependencies": {}
|
|
24
|
-
},
|
|
25
|
-
"prisma-mysql": {
|
|
26
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
27
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
28
|
-
"dependencies": {}
|
|
29
|
-
},
|
|
30
|
-
"prisma-sqlite": {
|
|
31
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
32
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
33
|
-
"dependencies": {}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"frameworkConfigs": {
|
|
37
|
-
"nextjs": {
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"next-auth": "^5.0.0"
|
|
40
|
-
},
|
|
41
|
-
"envVars": [
|
|
42
|
-
{
|
|
43
|
-
"key": "NEXTAUTH_SECRET",
|
|
44
|
-
"value": "",
|
|
45
|
-
"required": true
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"key": "NEXTAUTH_URL",
|
|
49
|
-
"value": "http://localhost:3000",
|
|
50
|
-
"required": true
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"key": "GOOGLE_CLIENT_ID",
|
|
54
|
-
"value": "",
|
|
55
|
-
"required": false
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"key": "GOOGLE_CLIENT_SECRET",
|
|
59
|
-
"value": "",
|
|
60
|
-
"required": false
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"key": "GITHUB_ID",
|
|
64
|
-
"value": "",
|
|
65
|
-
"required": false
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"key": "GITHUB_SECRET",
|
|
69
|
-
"value": "",
|
|
70
|
-
"required": false
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
"patches": [
|
|
74
|
-
{
|
|
75
|
-
"type": "create-file",
|
|
76
|
-
"description": "{{authDescription}}",
|
|
77
|
-
"source": "lib/{{authFile}}",
|
|
78
|
-
"destination": "{{lib}}/{{authFile}}"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"type": "create-file",
|
|
82
|
-
"description": "Create Auth.js API routes",
|
|
83
|
-
"source": "api/auth/[...nextauth]/route.ts",
|
|
84
|
-
"destination": "app/api/auth/[...nextauth]/route.ts"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"type": "create-file",
|
|
88
|
-
"description": "Create Auth.js client utilities",
|
|
89
|
-
"source": "lib/auth-client.ts",
|
|
90
|
-
"destination": "{{lib}}/auth-client.ts"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
20
|
}
|
|
94
21
|
}
|
|
95
22
|
}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { betterAuth } from "better-auth";
|
|
2
2
|
import { sendEmail } from "./email/email-service";
|
|
3
3
|
import { getVerificationEmailTemplate, getPasswordResetEmailTemplate } from "./email/email-templates";
|
|
4
|
-
{{
|
|
4
|
+
{{#if database=='prisma'}}
|
|
5
|
+
import { prisma } from "{{framework=='nextjs' ? '@/lib' : '.'}}/prisma";
|
|
6
|
+
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
7
|
+
{{/if}}
|
|
8
|
+
{{#if database=='mongoose'}}
|
|
9
|
+
import { mongoClient, db } from "{{framework=='nextjs' ? '@/lib' : '.'}}/db";
|
|
10
|
+
import { mongodbAdapter } from "better-auth/adapters/mongodb";
|
|
11
|
+
{{/if}}
|
|
5
12
|
|
|
6
13
|
export const auth = betterAuth({
|
|
7
|
-
{{
|
|
14
|
+
{{#if database=='prisma'}}
|
|
15
|
+
database: prismaAdapter(prisma),
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if database=='mongoose'}}
|
|
18
|
+
database: mongodbAdapter(db),
|
|
19
|
+
{{/if}}
|
|
8
20
|
user: {
|
|
9
21
|
additionalFields: {
|
|
10
22
|
role: {
|
|
@@ -16,14 +28,16 @@ export const auth = betterAuth({
|
|
|
16
28
|
},
|
|
17
29
|
emailAndPassword: {
|
|
18
30
|
enabled: true,
|
|
19
|
-
requireEmailVerification:
|
|
31
|
+
requireEmailVerification: {{feature:emailVerification}},
|
|
20
32
|
},
|
|
33
|
+
{{#if features.includes('socialAuth')}}
|
|
21
34
|
socialProviders: {
|
|
22
35
|
google: {
|
|
23
36
|
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
24
37
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
25
38
|
},
|
|
26
39
|
},
|
|
40
|
+
{{/if}}
|
|
27
41
|
emailVerification: {
|
|
28
42
|
sendVerificationEmail: async ({ user, url }) => {
|
|
29
43
|
const { html, text } = getVerificationEmailTemplate(user, url);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
model User {
|
|
3
|
-
id String @id {{
|
|
3
|
+
id String @id {{#if prismaProvider == postgresql}}@default(cuid()){{/if}}{{#if prismaProvider == mysql}}@default(uuid()){{/if}}{{#if prismaProvider == sqlite}}@default(uuid()){{/if}}
|
|
4
4
|
name String
|
|
5
5
|
email String
|
|
6
6
|
emailVerified Boolean @default(false)
|
|
@@ -16,14 +16,14 @@ model User {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
model Session {
|
|
19
|
-
id String @id {{
|
|
19
|
+
id String @id {{#if prismaProvider == postgresql}}@default(cuid()){{/if}}{{#if prismaProvider == mysql}}@default(uuid()){{/if}}{{#if prismaProvider == sqlite}}@default(uuid()){{/if}}
|
|
20
20
|
expiresAt DateTime
|
|
21
21
|
token String @unique
|
|
22
22
|
createdAt DateTime @default(now())
|
|
23
23
|
updatedAt DateTime @updatedAt
|
|
24
24
|
ipAddress String?
|
|
25
25
|
userAgent String?
|
|
26
|
-
userId String {{
|
|
26
|
+
userId String {{#if prismaProvider == postgresql}}{{/if}}{{#if prismaProvider == mysql}}{{/if}}{{#if prismaProvider == sqlite}}{{/if}}
|
|
27
27
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
28
28
|
|
|
29
29
|
@@index([userId])
|
|
@@ -31,10 +31,10 @@ model Session {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
model Account {
|
|
34
|
-
id String @id {{
|
|
34
|
+
id String @id {{#if prismaProvider == postgresql}}@default(cuid()){{/if}}{{#if prismaProvider == mysql}}@default(uuid()){{/if}}{{#if prismaProvider == sqlite}}@default(uuid()){{/if}}
|
|
35
35
|
accountId String
|
|
36
36
|
providerId String
|
|
37
|
-
userId String {{
|
|
37
|
+
userId String {{#if prismaProvider == postgresql}}{{/if}}{{#if prismaProvider == mysql}}{{/if}}{{#if prismaProvider == sqlite}}{{/if}}
|
|
38
38
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
39
39
|
accessToken String?
|
|
40
40
|
refreshToken String?
|
|
@@ -51,7 +51,7 @@ model Account {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
model Verification {
|
|
54
|
-
id String @id {{
|
|
54
|
+
id String @id {{#if prismaProvider == postgresql}}@default(cuid()){{/if}}{{#if prismaProvider == mysql}}@default(uuid()){{/if}}{{#if prismaProvider == sqlite}}@default(uuid()){{/if}}
|
|
55
55
|
identifier String
|
|
56
56
|
value String
|
|
57
57
|
expiresAt DateTime
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "better-auth",
|
|
3
|
+
"type": "auth",
|
|
4
|
+
"priority": 10,
|
|
5
|
+
"operations": [
|
|
6
|
+
{
|
|
7
|
+
"type": "create-file",
|
|
8
|
+
"description": "Create Better Auth configuration file",
|
|
9
|
+
"source": "lib/auth.ts",
|
|
10
|
+
"destination": "{{lib}}/auth.ts"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "create-file",
|
|
14
|
+
"description": "Create email service for sending emails",
|
|
15
|
+
"source": "lib/email-service.ts",
|
|
16
|
+
"destination": "{{lib}}/email/email-service.ts"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "create-file",
|
|
20
|
+
"description": "Create email templates",
|
|
21
|
+
"source": "lib/email-templates.ts",
|
|
22
|
+
"destination": "{{lib}}/email/email-templates.ts"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "create-file",
|
|
26
|
+
"description": "Create Better Auth API routes for Next.js",
|
|
27
|
+
"source": "api/auth/[...all]/route.ts",
|
|
28
|
+
"destination": "app/api/auth/[...all]/route.ts",
|
|
29
|
+
"condition": { "framework": "nextjs" }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "create-file",
|
|
33
|
+
"description": "Create Better Auth client for React",
|
|
34
|
+
"source": "lib/auth-client.ts",
|
|
35
|
+
"destination": "{{lib}}/auth-client.ts",
|
|
36
|
+
"condition": { "framework": "nextjs" }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "create-file",
|
|
40
|
+
"description": "Create Better Auth middleware for Next.js",
|
|
41
|
+
"destination": "middleware.ts",
|
|
42
|
+
"condition": { "framework": "nextjs" },
|
|
43
|
+
"content": "import { auth } from \"@/lib/auth\";\n\nexport default auth((req) => {\n console.log('middleware', req.auth)\n})\n\nexport const config = {\n matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],\n}"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "patch-file",
|
|
47
|
+
"description": "Add Better Auth routes to Express app",
|
|
48
|
+
"file": "src/app.ts",
|
|
49
|
+
"condition": { "framework": "express" },
|
|
50
|
+
"operations": [
|
|
51
|
+
{
|
|
52
|
+
"type": "add-import",
|
|
53
|
+
"imports": [
|
|
54
|
+
"import { auth } from \"@/lib/auth\";",
|
|
55
|
+
"import { toNodeHandler } from \"better-auth/node\";"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "add-code",
|
|
60
|
+
"after": "// routes",
|
|
61
|
+
"code": "\napp.all(\"/api/auth/*splat\", toNodeHandler(auth));"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"better-auth": "^1.4.12",
|
|
68
|
+
"nodemailer": "^7.0.12"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/nodemailer": "^6.4.17"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {},
|
|
74
|
+
"envVars": {
|
|
75
|
+
"BETTER_AUTH_SECRET": "",
|
|
76
|
+
"BETTER_AUTH_URL": "http://localhost:3000",
|
|
77
|
+
"EMAIL_HOST": "smtp.gmail.com",
|
|
78
|
+
"EMAIL_PORT": "587",
|
|
79
|
+
"EMAIL_USER": "",
|
|
80
|
+
"EMAIL_PASS": "",
|
|
81
|
+
"EMAIL_FROM": "noreply@yourapp.com"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -5,187 +5,33 @@
|
|
|
5
5
|
"category": "auth",
|
|
6
6
|
"provider": "better-auth",
|
|
7
7
|
"supportedFrameworks": ["nextjs", "express", "react-vite"],
|
|
8
|
+
"compatibility": {
|
|
9
|
+
"frameworks": ["nextjs", "express", "react-vite"],
|
|
10
|
+
"databases": ["prisma", "mongoose"],
|
|
11
|
+
"languages": ["typescript", "javascript"],
|
|
12
|
+
"packageManagers": ["npm", "yarn", "pnpm", "bun"]
|
|
13
|
+
},
|
|
8
14
|
"databaseAdapters": {
|
|
9
|
-
"common": {
|
|
10
|
-
"dependencies": {},
|
|
11
|
-
"devDependencies": {}
|
|
12
|
-
},
|
|
13
15
|
"prisma-postgresql": {
|
|
14
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
15
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@prisma/adapter-pg": "^5.0.0",
|
|
18
18
|
"pg": "^8.0.0"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"prisma-mongodb": {
|
|
22
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
23
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
24
22
|
"dependencies": {}
|
|
25
23
|
},
|
|
26
24
|
"prisma-mysql": {
|
|
27
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
28
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
29
25
|
"dependencies": {
|
|
30
26
|
"@prisma/adapter-mariadb": "^5.0.0",
|
|
31
27
|
"mysql2": "^3.0.0"
|
|
32
28
|
}
|
|
33
29
|
},
|
|
34
30
|
"prisma-sqlite": {
|
|
35
|
-
"schema": "files/schemas/prisma-schema.prisma",
|
|
36
|
-
"schemaDestination": "prisma/schema.prisma",
|
|
37
31
|
"dependencies": {
|
|
38
32
|
"@prisma/adapter-better-sqlite3": "^5.0.0",
|
|
39
33
|
"better-sqlite3": "^9.0.0"
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
|
-
},
|
|
43
|
-
"frameworkConfigs": {
|
|
44
|
-
"shared": {
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"better-auth": "^1.4.12",
|
|
47
|
-
"nodemailer": "^7.0.12"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@types/nodemailer": "^6.4.17"
|
|
51
|
-
},
|
|
52
|
-
"envVars": [
|
|
53
|
-
{
|
|
54
|
-
"key": "BETTER_AUTH_SECRET",
|
|
55
|
-
"value": "",
|
|
56
|
-
"required": true
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"key": "BETTER_AUTH_URL",
|
|
60
|
-
"value": "http://localhost:3000",
|
|
61
|
-
"required": true
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"key": "EMAIL_HOST",
|
|
65
|
-
"value": "smtp.gmail.com",
|
|
66
|
-
"required": true
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"key": "EMAIL_PORT",
|
|
70
|
-
"value": "587",
|
|
71
|
-
"required": true
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"key": "EMAIL_USER",
|
|
75
|
-
"value": "",
|
|
76
|
-
"required": true
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"key": "EMAIL_PASS",
|
|
80
|
-
"value": "",
|
|
81
|
-
"required": true
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"key": "EMAIL_FROM",
|
|
85
|
-
"value": "noreply@yourapp.com",
|
|
86
|
-
"required": true
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
|
-
"nextjs": {
|
|
91
|
-
"patches": [
|
|
92
|
-
{
|
|
93
|
-
"type": "create-file",
|
|
94
|
-
"description": "{{authDescription}}",
|
|
95
|
-
"source": "lib/{{authFile}}",
|
|
96
|
-
"destination": "{{lib}}/{{authFile}}"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"type": "create-file",
|
|
100
|
-
"description": "Create Better Auth API routes",
|
|
101
|
-
"source": "api/auth/[...all]/route.ts",
|
|
102
|
-
"destination": "app/api/auth/[...all]/route.ts"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"type": "create-file",
|
|
106
|
-
"description": "Create Better Auth client for React",
|
|
107
|
-
"source": "lib/auth-client.ts",
|
|
108
|
-
"destination": "{{lib}}/auth-client.ts"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
"type": "create-file",
|
|
112
|
-
"description": "Create email service for sending emails",
|
|
113
|
-
"source": "lib/email-service.ts",
|
|
114
|
-
"destination": "{{lib}}/email/email-service.ts"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"type": "create-file",
|
|
118
|
-
"description": "Create email templates",
|
|
119
|
-
"source": "lib/email-templates.ts",
|
|
120
|
-
"destination": "{{lib}}/email/email-templates.ts"
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
},
|
|
124
|
-
"express": {
|
|
125
|
-
"patches": [
|
|
126
|
-
{
|
|
127
|
-
"type": "create-file",
|
|
128
|
-
"description": "{{authDescription}}",
|
|
129
|
-
"source": "lib/{{authFile}}",
|
|
130
|
-
"destination": "{{lib}}/{{authFile}}"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"type": "patch-file",
|
|
134
|
-
"description": "Add Better Auth routes to Express app",
|
|
135
|
-
"file": "src/app.ts",
|
|
136
|
-
"operations": [
|
|
137
|
-
{
|
|
138
|
-
"type": "add-import",
|
|
139
|
-
"imports": [
|
|
140
|
-
"import { auth } from \"@/lib/auth\";",
|
|
141
|
-
"import { toNodeHandler } from \"better-auth/node\";"
|
|
142
|
-
]
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"type": "add-code",
|
|
146
|
-
"after": "// routes",
|
|
147
|
-
"code": "\napp.all(\"/api/auth/*splat\", toNodeHandler(auth));"
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"type": "create-file",
|
|
153
|
-
"description": "Create email service for sending emails",
|
|
154
|
-
"source": "lib/email-service.ts",
|
|
155
|
-
"destination": "{{lib}}/email/email-service.ts"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"type": "create-file",
|
|
159
|
-
"description": "Create email templates",
|
|
160
|
-
"source": "lib/email-templates.ts",
|
|
161
|
-
"destination": "{{lib}}/email/email-templates.ts"
|
|
162
|
-
}
|
|
163
|
-
]
|
|
164
|
-
},
|
|
165
|
-
"react-vite": {
|
|
166
|
-
"dependencies": {
|
|
167
|
-
"better-auth": "^1.4.12"
|
|
168
|
-
},
|
|
169
|
-
"envVars": [
|
|
170
|
-
{
|
|
171
|
-
"key": "BETTER_AUTH_SECRET",
|
|
172
|
-
"value": "",
|
|
173
|
-
"required": true
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"key": "BETTER_AUTH_URL",
|
|
177
|
-
"value": "http://localhost:3000",
|
|
178
|
-
"required": true
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
"patches": [
|
|
182
|
-
{
|
|
183
|
-
"type": "create-file",
|
|
184
|
-
"description": "Create Better Auth client for React",
|
|
185
|
-
"source": "lib/auth-client.ts",
|
|
186
|
-
"destination": "{{lib}}/auth-client.ts"
|
|
187
|
-
}
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
36
|
}
|
|
191
37
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import { ServerApiVersion } from "mongodb";
|
|
3
2
|
|
|
4
3
|
type MongooseCache = {
|
|
5
4
|
conn: typeof mongoose | null;
|
|
@@ -32,11 +31,7 @@ async function dbConnect(): Promise<typeof mongoose> {
|
|
|
32
31
|
bufferCommands: false,
|
|
33
32
|
connectTimeoutMS: 10000,
|
|
34
33
|
serverSelectionTimeoutMS: 10000,
|
|
35
|
-
serverApi:
|
|
36
|
-
version: ServerApiVersion.v1,
|
|
37
|
-
strict: true,
|
|
38
|
-
deprecationErrors: true,
|
|
39
|
-
},
|
|
34
|
+
// serverApi removed: not needed for mongoose-only connection
|
|
40
35
|
};
|
|
41
36
|
|
|
42
37
|
cached.promise = mongoose
|
|
@@ -65,4 +60,4 @@ async function dbConnect(): Promise<typeof mongoose> {
|
|
|
65
60
|
return cached.conn;
|
|
66
61
|
}
|
|
67
62
|
|
|
68
|
-
export
|
|
63
|
+
export { dbConnect as mongoose, dbConnect as connectMongoose };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mongoose",
|
|
3
|
+
"type": "database",
|
|
4
|
+
"priority": 5,
|
|
5
|
+
"operations": [
|
|
6
|
+
{
|
|
7
|
+
"type": "create-file",
|
|
8
|
+
"source": "lib/db.ts",
|
|
9
|
+
"destination": "src/lib/db.ts"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "create-file",
|
|
13
|
+
"source": "models/User.ts",
|
|
14
|
+
"destination": "src/lib/models.ts"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "create-file",
|
|
18
|
+
"destination": "scripts/seed.ts",
|
|
19
|
+
"condition": { "features": ["seed"] },
|
|
20
|
+
"content": "import dbConnect from '../src/lib/db'\nimport { User } from '../src/lib/models'\n\nasync function main() {\n await dbConnect()\n\n // Create a default user\n const user = await User.findOneAndUpdate(\n { email: 'admin@example.com' },\n {\n email: 'admin@example.com',\n name: 'Admin User',\n role: 'ADMIN',\n },\n { upsert: true, new: true }\n )\n\n console.log('Created user:', user)\n}\n\nmain().catch(console.error)"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"mongoose": "^8.8.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"db:seed": "tsx scripts/seed.ts"
|
|
29
|
+
},
|
|
30
|
+
"envVars": {
|
|
31
|
+
"MONGODB_URI": "mongodb://localhost:27017/database_name"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -6,50 +6,10 @@
|
|
|
6
6
|
"provider": "mongoose",
|
|
7
7
|
"database": "mongodb",
|
|
8
8
|
"supportedFrameworks": ["nextjs", "express"],
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
"envVars": {
|
|
17
|
-
"common": [
|
|
18
|
-
{
|
|
19
|
-
"key": "DATABASE_URL",
|
|
20
|
-
"value": "mongodb+srv://username:password@cluster.mongodb.net/mydb",
|
|
21
|
-
"required": true
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
"frameworkPatches": {
|
|
26
|
-
"express": {
|
|
27
|
-
"tsconfig.json": {
|
|
28
|
-
"merge": {
|
|
29
|
-
"compilerOptions": {
|
|
30
|
-
"baseUrl": ".",
|
|
31
|
-
"paths": {
|
|
32
|
-
"@/*": ["./*"]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"include": ["src/**/*", "lib/**/*"],
|
|
36
|
-
"exclude": ["node_modules", "dist"]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"patches": [
|
|
42
|
-
{
|
|
43
|
-
"type": "create-file",
|
|
44
|
-
"description": "{{dbDescription}}",
|
|
45
|
-
"source": "lib/{{dbFile}}",
|
|
46
|
-
"destination": "{{lib}}/{{dbFile}}"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"type": "create-file",
|
|
50
|
-
"description": "Create sample User model",
|
|
51
|
-
"source": "models/User.ts",
|
|
52
|
-
"destination": "{{models}}/User.ts"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
9
|
+
"compatibility": {
|
|
10
|
+
"frameworks": ["nextjs", "express"],
|
|
11
|
+
"databases": ["mongoose"],
|
|
12
|
+
"languages": ["typescript", "javascript"],
|
|
13
|
+
"packageManagers": ["npm", "yarn", "pnpm", "bun"]
|
|
14
|
+
}
|
|
55
15
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
{
|
|
4
|
-
|
|
1
|
+
import { PrismaClient } from '@prisma/client'
|
|
2
|
+
|
|
3
|
+
const globalForPrisma = globalThis as unknown as {
|
|
4
|
+
prisma: PrismaClient | undefined
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const prisma = globalForPrisma.prisma ?? new PrismaClient()
|
|
8
|
+
|
|
9
|
+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prisma",
|
|
3
|
+
"type": "database",
|
|
4
|
+
"priority": 5,
|
|
5
|
+
"operations": [
|
|
6
|
+
{
|
|
7
|
+
"type": "create-file",
|
|
8
|
+
"destination": "prisma/schema.prisma",
|
|
9
|
+
"content": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n provider = \"prisma-client-js\"\n}\n\ndatasource db {\n provider = \"{{prismaProvider}}\"\n}\n\nmodel User {\n id String @id {{#if prismaProvider==\"postgresql\"}}@default(cuid()){{/if}}{{#if prismaProvider!=\"postgresql\"}}@default(uuid()){{/if}}\n email String @unique\n name String?\n password String?\n role String @default(\"USER\")\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n {{#if auth==\"better-auth\"}}accounts Account[]\n sessions Session[]\n {{/if}}\n}\n\n{{#if auth==\"better-auth\"}}model Account {\n id String @id {{#if prismaProvider==\"postgresql\"}}@default(cuid()){{/if}}{{#if prismaProvider!=\"postgresql\"}}@default(uuid()){{/if}}\n accountId String\n providerId String\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n @@unique([providerId, accountId])\n}\n\nmodel Session {\n id String @id {{#if prismaProvider==\"postgresql\"}}@default(cuid()){{/if}}{{#if prismaProvider!=\"postgresql\"}}@default(uuid()){{/if}}\n expiresAt DateTime\n token String @unique\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n}\n{{/if}}"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "create-file",
|
|
13
|
+
"source": "prisma.config.ts",
|
|
14
|
+
"destination": "prisma.config.ts"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "create-file",
|
|
18
|
+
"source": "lib/prisma.ts",
|
|
19
|
+
"destination": "{{lib}}/prisma.ts"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "create-file",
|
|
23
|
+
"destination": "prisma/seed.ts",
|
|
24
|
+
"condition": { "features": ["seed"] },
|
|
25
|
+
"content": "import { PrismaClient } from '@prisma/client'\n\nconst prisma = new PrismaClient()\n\nasync function main() {\n // Create a default user\n const user = await prisma.user.upsert({\n where: { email: 'admin@example.com' },\n update: {},\n create: {\n email: 'admin@example.com',\n name: 'Admin User',\n role: 'ADMIN',\n },\n })\n console.log('Created user:', user)\n}\n\nmain()\n .then(async () => {\n await prisma.$disconnect()\n })\n .catch(async (e) => {\n console.error(e)\n await prisma.$disconnect()\n process.exit(1)\n })"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"prisma": "^7.2.0",
|
|
30
|
+
"@prisma/client": "^7.2.0",
|
|
31
|
+
"dotenv": "^16.4.5"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"prisma": "^7.2.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"db:generate": "prisma generate",
|
|
38
|
+
"db:push": "prisma db push",
|
|
39
|
+
"db:seed": "tsx prisma/seed.ts",
|
|
40
|
+
"db:migrate": "prisma migrate dev",
|
|
41
|
+
"db:studio": "prisma studio"
|
|
42
|
+
},
|
|
43
|
+
"envVars": {
|
|
44
|
+
"DATABASE_URL": "postgresql://username:password@localhost:5432/database_name"
|
|
45
|
+
}
|
|
46
|
+
}
|