stackkit-cli 0.4.2 → 0.4.3
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 +17 -10
- package/bin/stackkit.js +1 -1
- package/dist/commands/add.js +26 -24
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +34 -29
- package/dist/commands/list.js +12 -12
- package/dist/index.js +25 -23
- package/dist/types/index.d.ts +14 -14
- package/dist/utils/code-inject.d.ts +1 -1
- package/dist/utils/code-inject.js +6 -6
- package/dist/utils/detect.d.ts +1 -1
- package/dist/utils/detect.js +48 -44
- package/dist/utils/env-editor.js +20 -20
- package/dist/utils/files.js +4 -4
- package/dist/utils/json-editor.d.ts +3 -3
- package/dist/utils/json-editor.js +10 -14
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.js +8 -8
- package/dist/utils/package-manager.d.ts +2 -2
- package/dist/utils/package-manager.js +33 -26
- package/modules/auth/better-auth-express/adapters/mongoose-mongodb.ts +13 -0
- package/modules/auth/better-auth-express/adapters/prisma-mongodb.ts +15 -0
- package/modules/auth/better-auth-express/adapters/prisma-postgresql.ts +15 -0
- package/modules/auth/better-auth-express/files/lib/auth.ts +1 -1
- package/modules/auth/better-auth-express/files/routes/auth.ts +3 -3
- package/modules/auth/better-auth-express/files/schemas/prisma-mongodb-schema.prisma +72 -0
- package/modules/auth/better-auth-express/files/schemas/prisma-postgresql-schema.prisma +72 -0
- package/modules/auth/better-auth-express/module.json +26 -3
- package/modules/auth/better-auth-nextjs/adapters/mongoose-mongodb.ts +24 -0
- package/modules/auth/better-auth-nextjs/adapters/prisma-mongodb.ts +26 -0
- package/modules/auth/better-auth-nextjs/adapters/prisma-postgresql.ts +26 -0
- package/modules/auth/better-auth-nextjs/files/api/auth/[...all]/route.ts +2 -3
- package/modules/auth/better-auth-nextjs/files/lib/auth.ts +4 -4
- package/modules/auth/better-auth-nextjs/files/schemas/prisma-mongodb-schema.prisma +72 -0
- package/modules/auth/better-auth-nextjs/files/schemas/prisma-postgresql-schema.prisma +72 -0
- package/modules/auth/better-auth-nextjs/module.json +26 -5
- package/modules/auth/better-auth-react/files/lib/auth-client.ts +2 -2
- package/modules/auth/better-auth-react/module.json +7 -5
- package/modules/auth/clerk-express/files/lib/auth.ts +1 -1
- package/modules/auth/clerk-express/module.json +22 -8
- package/modules/auth/clerk-nextjs/files/lib/auth-provider.tsx +1 -1
- package/modules/auth/clerk-nextjs/files/middleware.ts +3 -3
- package/modules/auth/clerk-nextjs/module.json +50 -14
- package/modules/auth/clerk-react/files/lib/auth-provider.tsx +2 -2
- package/modules/auth/clerk-react/module.json +16 -7
- package/modules/database/mongoose-mongodb/files/lib/db.ts +3 -3
- package/modules/database/mongoose-mongodb/module.json +43 -6
- package/modules/database/prisma-mongodb/files/lib/db.ts +2 -2
- package/modules/database/prisma-mongodb/files/prisma/schema.prisma +1 -1
- package/modules/database/prisma-mongodb/module.json +28 -4
- package/modules/database/prisma-postgresql/files/lib/db.ts +2 -2
- package/modules/database/prisma-postgresql/files/prisma/schema.prisma +1 -1
- package/modules/database/prisma-postgresql/module.json +28 -4
- package/package.json +1 -1
- package/templates/express/.env.example +11 -0
- package/templates/express/eslint.config.cjs +42 -0
- package/templates/express/package.json +39 -0
- package/templates/express/src/app.ts +71 -0
- package/templates/express/src/config/env.ts +23 -0
- package/templates/express/src/middlewares/error.middleware.ts +18 -0
- package/templates/{bases/express-base → express}/src/server.ts +2 -2
- package/templates/express/template.json +44 -0
- package/templates/express/tsconfig.json +31 -0
- package/templates/{bases/nextjs-base → nextjs}/app/layout.tsx +1 -5
- package/templates/nextjs/app/page.tsx +57 -0
- package/templates/{bases/nextjs-base → nextjs}/package.json +2 -1
- package/templates/{bases/nextjs-base → nextjs}/template.json +13 -1
- package/templates/react-vite/.env.example +2 -0
- package/templates/react-vite/README.md +85 -0
- package/templates/react-vite/eslint.config.js +23 -0
- package/templates/{bases/react-vite-base → react-vite}/index.html +1 -0
- package/templates/{bases/react-vite-base → react-vite}/package.json +16 -2
- package/templates/react-vite/src/api/client.ts +47 -0
- package/templates/react-vite/src/api/services/user.service.ts +18 -0
- package/templates/react-vite/src/components/ErrorBoundary.tsx +51 -0
- package/templates/react-vite/src/components/Layout.tsx +13 -0
- package/templates/react-vite/src/components/Loading.tsx +8 -0
- package/templates/react-vite/src/components/SEO.tsx +49 -0
- package/templates/react-vite/src/config/constants.ts +5 -0
- package/templates/react-vite/src/hooks/index.ts +64 -0
- package/templates/react-vite/src/index.css +1 -0
- package/templates/react-vite/src/lib/queryClient.ts +12 -0
- package/templates/react-vite/src/main.tsx +22 -0
- package/templates/react-vite/src/pages/About.tsx +78 -0
- package/templates/react-vite/src/pages/Home.tsx +49 -0
- package/templates/react-vite/src/pages/NotFound.tsx +24 -0
- package/templates/react-vite/src/pages/UserProfile.tsx +40 -0
- package/templates/react-vite/src/router.tsx +33 -0
- package/templates/react-vite/src/types/api.d.ts +20 -0
- package/templates/react-vite/src/types/user.d.ts +6 -0
- package/templates/react-vite/src/utils/helpers.ts +51 -0
- package/templates/react-vite/src/utils/storage.ts +35 -0
- package/templates/react-vite/src/vite-env.d.ts +11 -0
- package/templates/react-vite/template.json +46 -0
- package/templates/react-vite/tsconfig.json +4 -0
- package/templates/react-vite/vite.config.ts +13 -0
- package/modules/database/drizzle-postgresql/files/drizzle.config.ts +0 -10
- package/modules/database/drizzle-postgresql/files/lib/db.ts +0 -7
- package/modules/database/drizzle-postgresql/files/lib/schema.ts +0 -8
- package/modules/database/drizzle-postgresql/module.json +0 -35
- package/templates/bases/express-base/.env.example +0 -2
- package/templates/bases/express-base/package.json +0 -23
- package/templates/bases/express-base/src/app.ts +0 -34
- package/templates/bases/express-base/src/config/env.ts +0 -14
- package/templates/bases/express-base/src/middlewares/error.middleware.ts +0 -12
- package/templates/bases/express-base/template.json +0 -7
- package/templates/bases/express-base/tsconfig.json +0 -14
- package/templates/bases/nextjs-base/app/page.tsx +0 -65
- package/templates/bases/react-vite-base/README.md +0 -73
- package/templates/bases/react-vite-base/eslint.config.js +0 -23
- package/templates/bases/react-vite-base/src/App.css +0 -42
- package/templates/bases/react-vite-base/src/App.tsx +0 -35
- package/templates/bases/react-vite-base/src/index.css +0 -68
- package/templates/bases/react-vite-base/src/main.tsx +0 -10
- package/templates/bases/react-vite-base/template.json +0 -19
- package/templates/bases/react-vite-base/tsconfig.json +0 -7
- package/templates/bases/react-vite-base/vite.config.ts +0 -7
- /package/templates/{bases/nextjs-base → nextjs}/README.md +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/app/favicon.ico +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/app/globals.css +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/eslint.config.mjs +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/next.config.ts +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/postcss.config.mjs +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/file.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/globe.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/next.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/vercel.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/window.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/tsconfig.json +0 -0
- /package/templates/{bases/react-vite-base → react-vite}/public/vite.svg +0 -0
- /package/templates/{bases/react-vite-base → react-vite}/src/assets/react.svg +0 -0
- /package/templates/{bases/react-vite-base → react-vite}/tsconfig.app.json +0 -0
- /package/templates/{bases/react-vite-base → react-vite}/tsconfig.node.json +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
generator client {
|
|
2
|
+
provider = "prisma-client-js"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
datasource db {
|
|
6
|
+
provider = "postgresql"
|
|
7
|
+
url = env("DATABASE_URL")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Better Auth models for PostgreSQL
|
|
11
|
+
model User {
|
|
12
|
+
id String @id @default(cuid())
|
|
13
|
+
name String
|
|
14
|
+
email String
|
|
15
|
+
emailVerified Boolean @default(false)
|
|
16
|
+
image String?
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
updatedAt DateTime @updatedAt
|
|
19
|
+
sessions Session[]
|
|
20
|
+
accounts Account[]
|
|
21
|
+
role String @default("USER")
|
|
22
|
+
|
|
23
|
+
@@unique([email])
|
|
24
|
+
@@map("user")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
model Session {
|
|
28
|
+
id String @id @default(cuid())
|
|
29
|
+
expiresAt DateTime
|
|
30
|
+
token String @unique
|
|
31
|
+
createdAt DateTime @default(now())
|
|
32
|
+
updatedAt DateTime @updatedAt
|
|
33
|
+
ipAddress String?
|
|
34
|
+
userAgent String?
|
|
35
|
+
userId String
|
|
36
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
37
|
+
|
|
38
|
+
@@index([userId])
|
|
39
|
+
@@map("session")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
model Account {
|
|
43
|
+
id String @id @default(cuid())
|
|
44
|
+
accountId String
|
|
45
|
+
providerId String
|
|
46
|
+
userId String
|
|
47
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
48
|
+
accessToken String?
|
|
49
|
+
refreshToken String?
|
|
50
|
+
idToken String?
|
|
51
|
+
accessTokenExpiresAt DateTime?
|
|
52
|
+
refreshTokenExpiresAt DateTime?
|
|
53
|
+
scope String?
|
|
54
|
+
password String?
|
|
55
|
+
createdAt DateTime @default(now())
|
|
56
|
+
updatedAt DateTime @updatedAt
|
|
57
|
+
|
|
58
|
+
@@index([userId])
|
|
59
|
+
@@map("account")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
model Verification {
|
|
63
|
+
id String @id @default(cuid())
|
|
64
|
+
identifier String
|
|
65
|
+
value String
|
|
66
|
+
expiresAt DateTime
|
|
67
|
+
createdAt DateTime @default(now())
|
|
68
|
+
updatedAt DateTime @updatedAt
|
|
69
|
+
|
|
70
|
+
@@index([identifier])
|
|
71
|
+
@@map("verification")
|
|
72
|
+
}
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "auth",
|
|
2
|
+
"name": "better-auth-express",
|
|
3
3
|
"displayName": "Better Auth (Express)",
|
|
4
4
|
"description": "Modern authentication with Better Auth for Express",
|
|
5
5
|
"category": "auth",
|
|
6
6
|
"supportedFrameworks": ["express"],
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"databaseAdapters": {
|
|
8
|
+
"prisma-postgresql": {
|
|
9
|
+
"adapter": "adapters/prisma-postgresql.ts",
|
|
10
|
+
"schema": "files/schemas/prisma-postgresql-schema.prisma",
|
|
11
|
+
"schemaDestination": "prisma/schema.prisma",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"better-auth": "^1.1.4",
|
|
14
|
+
"@better-auth/prisma": "^1.1.4"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"prisma-mongodb": {
|
|
18
|
+
"adapter": "adapters/prisma-mongodb.ts",
|
|
19
|
+
"schema": "files/schemas/prisma-mongodb-schema.prisma",
|
|
20
|
+
"schemaDestination": "prisma/schema.prisma",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"better-auth": "^1.1.4",
|
|
23
|
+
"@better-auth/prisma": "^1.1.4"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"mongoose-mongodb": {
|
|
27
|
+
"adapter": "adapters/mongoose-mongodb.ts",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"better-auth": "^1.1.4"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
9
32
|
},
|
|
10
33
|
"envVars": [
|
|
11
34
|
{
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { client } from "@/lib/db";
|
|
2
|
+
import { betterAuth } from "better-auth";
|
|
3
|
+
import { mongodbAdapter } from "better-auth/adapters/mongodb";
|
|
4
|
+
|
|
5
|
+
export const auth = betterAuth({
|
|
6
|
+
database: mongodbAdapter(client),
|
|
7
|
+
emailAndPassword: {
|
|
8
|
+
enabled: true,
|
|
9
|
+
},
|
|
10
|
+
socialProviders: {
|
|
11
|
+
// Uncomment to add OAuth providers
|
|
12
|
+
// google: {
|
|
13
|
+
// clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
14
|
+
// clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
15
|
+
// },
|
|
16
|
+
// github: {
|
|
17
|
+
// clientId: process.env.GITHUB_CLIENT_ID!,
|
|
18
|
+
// clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
19
|
+
// },
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type Session = typeof auth.$Infer.Session;
|
|
24
|
+
export type User = typeof auth.$Infer.User;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { prisma } from "@/lib/db";
|
|
2
|
+
import { prismaAdapter } from "@better-auth/prisma";
|
|
3
|
+
import { betterAuth } from "better-auth";
|
|
4
|
+
|
|
5
|
+
export const auth = betterAuth({
|
|
6
|
+
database: prismaAdapter(prisma, {
|
|
7
|
+
provider: "mongodb",
|
|
8
|
+
}),
|
|
9
|
+
emailAndPassword: {
|
|
10
|
+
enabled: true,
|
|
11
|
+
},
|
|
12
|
+
socialProviders: {
|
|
13
|
+
// Uncomment to add OAuth providers
|
|
14
|
+
// google: {
|
|
15
|
+
// clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
16
|
+
// clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
17
|
+
// },
|
|
18
|
+
// github: {
|
|
19
|
+
// clientId: process.env.GITHUB_CLIENT_ID!,
|
|
20
|
+
// clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
21
|
+
// },
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type Session = typeof auth.$Infer.Session;
|
|
26
|
+
export type User = typeof auth.$Infer.User;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { prisma } from "@/lib/db";
|
|
2
|
+
import { prismaAdapter } from "@better-auth/prisma";
|
|
3
|
+
import { betterAuth } from "better-auth";
|
|
4
|
+
|
|
5
|
+
export const auth = betterAuth({
|
|
6
|
+
database: prismaAdapter(prisma, {
|
|
7
|
+
provider: "postgresql",
|
|
8
|
+
}),
|
|
9
|
+
emailAndPassword: {
|
|
10
|
+
enabled: true,
|
|
11
|
+
},
|
|
12
|
+
socialProviders: {
|
|
13
|
+
// Uncomment to add OAuth providers
|
|
14
|
+
// google: {
|
|
15
|
+
// clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
16
|
+
// clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
17
|
+
// },
|
|
18
|
+
// github: {
|
|
19
|
+
// clientId: process.env.GITHUB_CLIENT_ID!,
|
|
20
|
+
// clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
21
|
+
// },
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type Session = typeof auth.$Infer.Session;
|
|
26
|
+
export type User = typeof auth.$Infer.User;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { prismaAdapter } from
|
|
2
|
-
import { betterAuth } from
|
|
3
|
-
import { prisma } from
|
|
1
|
+
import { prismaAdapter } from "@better-auth/prisma";
|
|
2
|
+
import { betterAuth } from "better-auth";
|
|
3
|
+
import { prisma } from "./db";
|
|
4
4
|
|
|
5
5
|
export const auth = betterAuth({
|
|
6
6
|
database: prismaAdapter(prisma, {
|
|
7
|
-
provider:
|
|
7
|
+
provider: "postgresql", // Change to 'mongodb' if using MongoDB
|
|
8
8
|
}),
|
|
9
9
|
emailAndPassword: {
|
|
10
10
|
enabled: true,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
generator client {
|
|
2
|
+
provider = "prisma-client-js"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
datasource db {
|
|
6
|
+
provider = "mongodb"
|
|
7
|
+
url = env("DATABASE_URL")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Better Auth models for MongoDB
|
|
11
|
+
model User {
|
|
12
|
+
id String @id @default(auto()) @map("_id") @db.ObjectId
|
|
13
|
+
name String
|
|
14
|
+
email String
|
|
15
|
+
emailVerified Boolean @default(false)
|
|
16
|
+
image String?
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
updatedAt DateTime @updatedAt
|
|
19
|
+
sessions Session[]
|
|
20
|
+
accounts Account[]
|
|
21
|
+
role String @default("USER")
|
|
22
|
+
|
|
23
|
+
@@unique([email])
|
|
24
|
+
@@map("user")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
model Session {
|
|
28
|
+
id String @id @default(auto()) @map("_id") @db.ObjectId
|
|
29
|
+
expiresAt DateTime
|
|
30
|
+
token String @unique
|
|
31
|
+
createdAt DateTime @default(now())
|
|
32
|
+
updatedAt DateTime @updatedAt
|
|
33
|
+
ipAddress String?
|
|
34
|
+
userAgent String?
|
|
35
|
+
userId String @db.ObjectId
|
|
36
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
37
|
+
|
|
38
|
+
@@index([userId])
|
|
39
|
+
@@map("session")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
model Account {
|
|
43
|
+
id String @id @default(auto()) @map("_id") @db.ObjectId
|
|
44
|
+
accountId String
|
|
45
|
+
providerId String
|
|
46
|
+
userId String @db.ObjectId
|
|
47
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
48
|
+
accessToken String?
|
|
49
|
+
refreshToken String?
|
|
50
|
+
idToken String?
|
|
51
|
+
accessTokenExpiresAt DateTime?
|
|
52
|
+
refreshTokenExpiresAt DateTime?
|
|
53
|
+
scope String?
|
|
54
|
+
password String?
|
|
55
|
+
createdAt DateTime @default(now())
|
|
56
|
+
updatedAt DateTime @updatedAt
|
|
57
|
+
|
|
58
|
+
@@index([userId])
|
|
59
|
+
@@map("account")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
model Verification {
|
|
63
|
+
id String @id @default(auto()) @map("_id") @db.ObjectId
|
|
64
|
+
identifier String
|
|
65
|
+
value String
|
|
66
|
+
expiresAt DateTime
|
|
67
|
+
createdAt DateTime @default(now())
|
|
68
|
+
updatedAt DateTime @updatedAt
|
|
69
|
+
|
|
70
|
+
@@index([identifier])
|
|
71
|
+
@@map("verification")
|
|
72
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
generator client {
|
|
2
|
+
provider = "prisma-client-js"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
datasource db {
|
|
6
|
+
provider = "postgresql"
|
|
7
|
+
url = env("DATABASE_URL")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Better Auth models for PostgreSQL
|
|
11
|
+
model User {
|
|
12
|
+
id String @id @default(cuid())
|
|
13
|
+
name String
|
|
14
|
+
email String
|
|
15
|
+
emailVerified Boolean @default(false)
|
|
16
|
+
image String?
|
|
17
|
+
createdAt DateTime @default(now())
|
|
18
|
+
updatedAt DateTime @updatedAt
|
|
19
|
+
sessions Session[]
|
|
20
|
+
accounts Account[]
|
|
21
|
+
role String @default("USER")
|
|
22
|
+
|
|
23
|
+
@@unique([email])
|
|
24
|
+
@@map("user")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
model Session {
|
|
28
|
+
id String @id @default(cuid())
|
|
29
|
+
expiresAt DateTime
|
|
30
|
+
token String @unique
|
|
31
|
+
createdAt DateTime @default(now())
|
|
32
|
+
updatedAt DateTime @updatedAt
|
|
33
|
+
ipAddress String?
|
|
34
|
+
userAgent String?
|
|
35
|
+
userId String
|
|
36
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
37
|
+
|
|
38
|
+
@@index([userId])
|
|
39
|
+
@@map("session")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
model Account {
|
|
43
|
+
id String @id @default(cuid())
|
|
44
|
+
accountId String
|
|
45
|
+
providerId String
|
|
46
|
+
userId String
|
|
47
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
48
|
+
accessToken String?
|
|
49
|
+
refreshToken String?
|
|
50
|
+
idToken String?
|
|
51
|
+
accessTokenExpiresAt DateTime?
|
|
52
|
+
refreshTokenExpiresAt DateTime?
|
|
53
|
+
scope String?
|
|
54
|
+
password String?
|
|
55
|
+
createdAt DateTime @default(now())
|
|
56
|
+
updatedAt DateTime @updatedAt
|
|
57
|
+
|
|
58
|
+
@@index([userId])
|
|
59
|
+
@@map("account")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
model Verification {
|
|
63
|
+
id String @id @default(cuid())
|
|
64
|
+
identifier String
|
|
65
|
+
value String
|
|
66
|
+
expiresAt DateTime
|
|
67
|
+
createdAt DateTime @default(now())
|
|
68
|
+
updatedAt DateTime @updatedAt
|
|
69
|
+
|
|
70
|
+
@@index([identifier])
|
|
71
|
+
@@map("verification")
|
|
72
|
+
}
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "auth",
|
|
2
|
+
"name": "better-auth-nextjs",
|
|
3
3
|
"displayName": "Better Auth (Next.js)",
|
|
4
4
|
"description": "Modern authentication with Better Auth for Next.js App Router",
|
|
5
5
|
"category": "auth",
|
|
6
6
|
"provider": "better-auth",
|
|
7
7
|
"supportedFrameworks": ["nextjs"],
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"databaseAdapters": {
|
|
9
|
+
"prisma-postgresql": {
|
|
10
|
+
"adapter": "adapters/prisma-postgresql.ts",
|
|
11
|
+
"schema": "files/schemas/prisma-postgresql-schema.prisma",
|
|
12
|
+
"schemaDestination": "prisma/schema.prisma",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"better-auth": "^1.1.4",
|
|
15
|
+
"@better-auth/prisma": "^1.1.4"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"prisma-mongodb": {
|
|
19
|
+
"adapter": "adapters/prisma-mongodb.ts",
|
|
20
|
+
"schema": "files/schemas/prisma-mongodb-schema.prisma",
|
|
21
|
+
"schemaDestination": "prisma/schema.prisma",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"better-auth": "^1.1.4",
|
|
24
|
+
"@better-auth/prisma": "^1.1.4"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"mongoose-mongodb": {
|
|
28
|
+
"adapter": "adapters/mongoose-mongodb.ts",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"better-auth": "^1.1.4"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
12
33
|
},
|
|
13
34
|
"envVars": [
|
|
14
35
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createAuthClient } from
|
|
1
|
+
import { createAuthClient } from "better-auth/react";
|
|
2
2
|
|
|
3
3
|
export const authClient = createAuthClient({
|
|
4
4
|
/** The base URL of the server (optional if you're using the same domain) */
|
|
5
|
-
baseURL: import.meta.env.VITE_AUTH_URL ||
|
|
5
|
+
baseURL: import.meta.env.VITE_AUTH_URL || "http://localhost:3000",
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
// Export specific methods for convenience
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "auth",
|
|
2
|
+
"name": "better-auth-react",
|
|
3
3
|
"displayName": "Better Auth (React)",
|
|
4
4
|
"description": "Client-side authentication with Better Auth for React",
|
|
5
5
|
"category": "auth",
|
|
6
|
-
"
|
|
6
|
+
"provider": "better-auth",
|
|
7
|
+
"supportedFrameworks": ["react-vite"],
|
|
7
8
|
"dependencies": {
|
|
8
|
-
"better-auth": "^1.
|
|
9
|
+
"better-auth": "^1.1.4"
|
|
9
10
|
},
|
|
11
|
+
"devDependencies": {},
|
|
10
12
|
"envVars": [
|
|
11
13
|
{
|
|
12
14
|
"key": "VITE_AUTH_URL",
|
|
13
15
|
"value": "http://localhost:3000",
|
|
14
|
-
"description": "Base URL of your auth server
|
|
15
|
-
"required":
|
|
16
|
+
"description": "Base URL of your auth server",
|
|
17
|
+
"required": true
|
|
16
18
|
}
|
|
17
19
|
],
|
|
18
20
|
"patches": [
|
|
@@ -3,18 +3,32 @@
|
|
|
3
3
|
"displayName": "Clerk (Express)",
|
|
4
4
|
"description": "Clerk Authentication for Express.js",
|
|
5
5
|
"category": "auth",
|
|
6
|
-
"
|
|
6
|
+
"provider": "clerk",
|
|
7
|
+
"supportedFrameworks": ["express"],
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"@clerk/express": "^1.4.5"
|
|
9
10
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
"devDependencies": {},
|
|
12
|
+
"envVars": [
|
|
13
|
+
{
|
|
14
|
+
"key": "CLERK_PUBLISHABLE_KEY",
|
|
15
|
+
"value": "",
|
|
16
|
+
"description": "Clerk publishable key (from Clerk dashboard)",
|
|
17
|
+
"required": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"key": "CLERK_SECRET_KEY",
|
|
21
|
+
"value": "",
|
|
22
|
+
"description": "Clerk secret key (from Clerk dashboard)",
|
|
23
|
+
"required": true
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"patches": [
|
|
15
27
|
{
|
|
16
|
-
"
|
|
17
|
-
"
|
|
28
|
+
"type": "create-file",
|
|
29
|
+
"description": "Create Clerk auth middleware",
|
|
30
|
+
"source": "lib/auth.ts",
|
|
31
|
+
"destination": "{{lib}}/auth.ts"
|
|
18
32
|
}
|
|
19
33
|
]
|
|
20
34
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { authMiddleware } from
|
|
1
|
+
import { authMiddleware } from "@clerk/nextjs";
|
|
2
2
|
|
|
3
3
|
export default authMiddleware({
|
|
4
|
-
publicRoutes: [
|
|
4
|
+
publicRoutes: ["/"],
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
export const config = {
|
|
8
|
-
matcher: [
|
|
8
|
+
matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"],
|
|
9
9
|
};
|
|
@@ -1,27 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clerk-nextjs",
|
|
3
3
|
"displayName": "Clerk (Next.js)",
|
|
4
|
-
"description": "Clerk Authentication for Next.js",
|
|
4
|
+
"description": "Clerk Authentication for Next.js App Router",
|
|
5
5
|
"category": "auth",
|
|
6
|
-
"
|
|
6
|
+
"provider": "clerk",
|
|
7
|
+
"supportedFrameworks": ["nextjs"],
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"@clerk/nextjs": "^6.10.2"
|
|
9
10
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
"devDependencies": {},
|
|
12
|
+
"envVars": [
|
|
13
|
+
{
|
|
14
|
+
"key": "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
|
|
15
|
+
"value": "",
|
|
16
|
+
"description": "Clerk publishable key (from Clerk dashboard)",
|
|
17
|
+
"required": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"key": "CLERK_SECRET_KEY",
|
|
21
|
+
"value": "",
|
|
22
|
+
"description": "Clerk secret key (from Clerk dashboard)",
|
|
23
|
+
"required": true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"key": "NEXT_PUBLIC_CLERK_SIGN_IN_URL",
|
|
27
|
+
"value": "/sign-in",
|
|
28
|
+
"description": "Sign in page URL",
|
|
29
|
+
"required": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"key": "NEXT_PUBLIC_CLERK_SIGN_UP_URL",
|
|
33
|
+
"value": "/sign-up",
|
|
34
|
+
"description": "Sign up page URL",
|
|
35
|
+
"required": true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"key": "NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL",
|
|
39
|
+
"value": "/",
|
|
40
|
+
"description": "Redirect URL after sign in",
|
|
41
|
+
"required": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"key": "NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL",
|
|
45
|
+
"value": "/",
|
|
46
|
+
"description": "Redirect URL after sign up",
|
|
47
|
+
"required": true
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"patches": [
|
|
19
51
|
{
|
|
20
|
-
"
|
|
21
|
-
"
|
|
52
|
+
"type": "create-file",
|
|
53
|
+
"description": "Create Clerk auth provider",
|
|
54
|
+
"source": "lib/auth-provider.tsx",
|
|
55
|
+
"destination": "{{lib}}/auth-provider.tsx"
|
|
22
56
|
},
|
|
23
57
|
{
|
|
24
|
-
"
|
|
58
|
+
"type": "create-file",
|
|
59
|
+
"description": "Create Clerk middleware",
|
|
60
|
+
"source": "middleware.ts",
|
|
25
61
|
"destination": "middleware.ts"
|
|
26
62
|
}
|
|
27
63
|
]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ClerkProvider } from
|
|
1
|
+
import { ClerkProvider } from "@clerk/clerk-react";
|
|
2
2
|
|
|
3
3
|
const publishableKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
|
|
4
4
|
|
|
5
5
|
if (!publishableKey) {
|
|
6
|
-
throw new Error(
|
|
6
|
+
throw new Error("Missing Publishable Key");
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|
@@ -3,17 +3,26 @@
|
|
|
3
3
|
"displayName": "Clerk (React)",
|
|
4
4
|
"description": "Clerk Authentication for React",
|
|
5
5
|
"category": "auth",
|
|
6
|
-
"
|
|
6
|
+
"provider": "clerk",
|
|
7
|
+
"supportedFrameworks": ["react-vite"],
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"@clerk/clerk-react": "^5.19.2"
|
|
9
10
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"devDependencies": {},
|
|
12
|
+
"envVars": [
|
|
13
|
+
{
|
|
14
|
+
"key": "VITE_CLERK_PUBLISHABLE_KEY",
|
|
15
|
+
"value": "",
|
|
16
|
+
"description": "Clerk publishable key (from Clerk dashboard)",
|
|
17
|
+
"required": true
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"patches": [
|
|
14
21
|
{
|
|
15
|
-
"
|
|
16
|
-
"
|
|
22
|
+
"type": "create-file",
|
|
23
|
+
"description": "Create Clerk auth provider",
|
|
24
|
+
"source": "lib/auth-provider.tsx",
|
|
25
|
+
"destination": "src/lib/auth-provider.tsx"
|
|
17
26
|
}
|
|
18
27
|
]
|
|
19
28
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import mongoose from
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
2
|
|
|
3
|
-
const MONGODB_URI = process.env.MONGODB_URI ||
|
|
3
|
+
const MONGODB_URI = process.env.MONGODB_URI || "mongodb://localhost:27017/myapp";
|
|
4
4
|
|
|
5
5
|
if (!MONGODB_URI) {
|
|
6
|
-
throw new Error(
|
|
6
|
+
throw new Error("Please define the MONGODB_URI environment variable");
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
let cached = global.mongoose;
|