create-stackkit-app 0.4.3 → 0.4.4

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 (71) hide show
  1. package/bin/create-stackkit.js +10 -1
  2. package/dist/index.js +1 -0
  3. package/dist/lib/create-project.js +79 -539
  4. package/dist/lib/utils/config-utils.d.ts +2 -0
  5. package/dist/lib/utils/config-utils.js +33 -0
  6. package/dist/lib/utils/file-utils.d.ts +8 -0
  7. package/dist/lib/utils/file-utils.js +75 -0
  8. package/dist/lib/utils/git-utils.d.ts +1 -0
  9. package/dist/lib/utils/git-utils.js +9 -0
  10. package/dist/lib/utils/js-conversion.d.ts +1 -0
  11. package/dist/lib/utils/js-conversion.js +244 -0
  12. package/dist/lib/utils/module-utils.d.ts +2 -0
  13. package/dist/lib/utils/module-utils.js +311 -0
  14. package/dist/lib/utils/package-utils.d.ts +1 -0
  15. package/dist/lib/utils/package-utils.js +39 -0
  16. package/modules/auth/better-auth/files/lib/auth.ts +13 -0
  17. package/modules/auth/better-auth/files/schemas/prisma-schema.prisma +63 -0
  18. package/modules/auth/better-auth/module.json +54 -0
  19. package/modules/auth/clerk/module.json +115 -0
  20. package/modules/database/mongoose-mongodb/files/lib/db.ts +44 -6
  21. package/modules/database/mongoose-mongodb/files/models/User.ts +39 -0
  22. package/modules/database/mongoose-mongodb/module.json +27 -12
  23. package/modules/database/prisma/files/lib/prisma.ts +6 -0
  24. package/modules/database/prisma/files/prisma/schema.prisma +8 -0
  25. package/modules/database/prisma/files/prisma.config.ts +12 -0
  26. package/modules/database/prisma/module.json +140 -0
  27. package/package.json +7 -3
  28. package/templates/express/.env.example +2 -10
  29. package/templates/express/package.json +12 -18
  30. package/templates/express/src/app.ts +9 -29
  31. package/templates/express/src/config/env.ts +3 -14
  32. package/templates/express/src/features/auth/auth.controller.ts +48 -0
  33. package/templates/express/src/features/auth/auth.route.ts +10 -0
  34. package/templates/express/src/features/auth/auth.service.ts +21 -0
  35. package/templates/express/src/middlewares/error.middleware.ts +2 -2
  36. package/templates/express/src/server.ts +1 -1
  37. package/templates/express/template.json +1 -5
  38. package/templates/express/tsconfig.json +0 -1
  39. package/dist/lib/template-composer.d.ts +0 -16
  40. package/dist/lib/template-composer.js +0 -197
  41. package/modules/auth/better-auth-express/adapters/mongoose-mongodb.ts +0 -13
  42. package/modules/auth/better-auth-express/adapters/prisma-mongodb.ts +0 -15
  43. package/modules/auth/better-auth-express/adapters/prisma-postgresql.ts +0 -15
  44. package/modules/auth/better-auth-express/files/lib/auth.ts +0 -16
  45. package/modules/auth/better-auth-express/files/routes/auth.ts +0 -12
  46. package/modules/auth/better-auth-express/files/schemas/prisma-mongodb-schema.prisma +0 -72
  47. package/modules/auth/better-auth-express/files/schemas/prisma-postgresql-schema.prisma +0 -72
  48. package/modules/auth/better-auth-express/module.json +0 -61
  49. package/modules/auth/better-auth-nextjs/adapters/mongoose-mongodb.ts +0 -24
  50. package/modules/auth/better-auth-nextjs/adapters/prisma-mongodb.ts +0 -26
  51. package/modules/auth/better-auth-nextjs/adapters/prisma-postgresql.ts +0 -26
  52. package/modules/auth/better-auth-nextjs/files/lib/auth.ts +0 -26
  53. package/modules/auth/better-auth-nextjs/files/schemas/prisma-mongodb-schema.prisma +0 -72
  54. package/modules/auth/better-auth-nextjs/files/schemas/prisma-postgresql-schema.prisma +0 -72
  55. package/modules/auth/better-auth-nextjs/module.json +0 -62
  56. package/modules/auth/better-auth-react/files/lib/auth-client.ts +0 -9
  57. package/modules/auth/better-auth-react/module.json +0 -28
  58. package/modules/auth/clerk-express/module.json +0 -34
  59. package/modules/auth/clerk-nextjs/module.json +0 -64
  60. package/modules/auth/clerk-react/module.json +0 -28
  61. package/modules/database/prisma-mongodb/files/lib/db.ts +0 -9
  62. package/modules/database/prisma-mongodb/files/prisma/schema.prisma +0 -17
  63. package/modules/database/prisma-mongodb/module.json +0 -60
  64. package/modules/database/prisma-postgresql/files/lib/db.ts +0 -9
  65. package/modules/database/prisma-postgresql/files/prisma/schema.prisma +0 -17
  66. package/modules/database/prisma-postgresql/module.json +0 -60
  67. /package/modules/auth/{better-auth-nextjs → better-auth}/files/api/auth/[...all]/route.ts +0 -0
  68. /package/modules/auth/{clerk-express/files/lib → clerk/files/express}/auth.ts +0 -0
  69. /package/modules/auth/{clerk-nextjs/files/lib → clerk/files/nextjs}/auth-provider.tsx +0 -0
  70. /package/modules/auth/{clerk-nextjs/files → clerk/files/nextjs}/middleware.ts +0 -0
  71. /package/modules/auth/{clerk-react/files/lib → clerk/files/react}/auth-provider.tsx +0 -0
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TemplateComposer = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- class TemplateComposer {
10
- constructor(templatesDir) {
11
- this.templatesDir = templatesDir;
12
- }
13
- /**
14
- * Compose a project from base + database + auth selections
15
- */
16
- async compose(targetDir, framework, database, auth) {
17
- const configs = [];
18
- const filesToCopy = [];
19
- // 1. Load base framework template
20
- const baseConfig = await this.loadConfig(path_1.default.join(this.templatesDir, framework));
21
- configs.push(baseConfig);
22
- // Copy base files
23
- const baseFiles = await this.getBaseFiles(framework);
24
- filesToCopy.push(...baseFiles);
25
- // 2. Load database configuration if not "none"
26
- if (database !== "none") {
27
- const dbConfig = await this.loadConfig(path_1.default.join(this.templatesDir, "databases", database));
28
- // Check compatibility
29
- if (dbConfig.compatibleWith?.frameworks &&
30
- !dbConfig.compatibleWith.frameworks.includes(framework)) {
31
- throw new Error(`${dbConfig.displayName} is not compatible with ${framework}`);
32
- }
33
- configs.push(dbConfig);
34
- // Copy database files
35
- const dbDir = path_1.default.join(this.templatesDir, "databases", database);
36
- const dbFiles = await this.collectFiles(dbDir);
37
- filesToCopy.push(...dbFiles.map((f) => ({
38
- source: f,
39
- dest: path_1.default.join(targetDir, f.replace(dbDir + path_1.default.sep, "")),
40
- })));
41
- }
42
- // 3. Load auth configuration if not "none"
43
- if (auth !== "none") {
44
- const authKey = this.getAuthKey(framework, auth);
45
- const authDir = path_1.default.join(this.templatesDir, "auth", authKey);
46
- if (await fs_extra_1.default.pathExists(authDir)) {
47
- const authConfig = await this.loadConfig(authDir);
48
- // Check compatibility
49
- if (authConfig.compatibleWith?.frameworks &&
50
- !authConfig.compatibleWith.frameworks.includes(framework)) {
51
- throw new Error(`${authConfig.displayName} is not compatible with ${framework}`);
52
- }
53
- if (authConfig.compatibleWith?.databases &&
54
- !authConfig.compatibleWith.databases.includes(database)) {
55
- throw new Error(`${authConfig.displayName} is not compatible with ${database}`);
56
- }
57
- configs.push(authConfig);
58
- // Copy auth files
59
- const authFiles = await this.collectFiles(authDir);
60
- filesToCopy.push(...authFiles.map((f) => ({
61
- source: f,
62
- dest: path_1.default.join(targetDir, f.replace(authDir + path_1.default.sep, "")),
63
- })));
64
- }
65
- }
66
- // 4. Merge all configurations
67
- const mergedConfig = this.mergeConfigs(configs);
68
- // 5. Copy all files
69
- await this.copyFiles(filesToCopy);
70
- // 6. Create/update package.json
71
- await this.writePackageJson(targetDir, mergedConfig);
72
- // 7. Create/update .env
73
- await this.writeEnvFile(targetDir, mergedConfig);
74
- }
75
- async loadConfig(dir) {
76
- const configPath = path_1.default.join(dir, "config.json");
77
- const templatePath = path_1.default.join(dir, "template.json");
78
- if (await fs_extra_1.default.pathExists(configPath)) {
79
- return await fs_extra_1.default.readJson(configPath);
80
- }
81
- else if (await fs_extra_1.default.pathExists(templatePath)) {
82
- return await fs_extra_1.default.readJson(templatePath);
83
- }
84
- throw new Error(`No configuration found in ${dir}`);
85
- }
86
- async getBaseFiles(framework) {
87
- // For now, use existing complete template
88
- // In future, this will use minimal base templates
89
- const baseDir = path_1.default.join(this.templatesDir, "next-prisma-postgres-shadcn");
90
- const files = await this.collectFiles(baseDir);
91
- return files.map((source) => ({
92
- source,
93
- dest: source.replace(baseDir, ""),
94
- }));
95
- }
96
- async collectFiles(dir, exclude = ["config.json", "template.json", "node_modules"]) {
97
- const files = [];
98
- if (!(await fs_extra_1.default.pathExists(dir))) {
99
- return files;
100
- }
101
- const entries = await fs_extra_1.default.readdir(dir, { withFileTypes: true });
102
- for (const entry of entries) {
103
- if (exclude.includes(entry.name))
104
- continue;
105
- const fullPath = path_1.default.join(dir, entry.name);
106
- if (entry.isDirectory()) {
107
- const subFiles = await this.collectFiles(fullPath, exclude);
108
- files.push(...subFiles);
109
- }
110
- else {
111
- files.push(fullPath);
112
- }
113
- }
114
- return files;
115
- }
116
- async copyFiles(files) {
117
- for (const { source, dest } of files) {
118
- await fs_extra_1.default.ensureDir(path_1.default.dirname(dest));
119
- await fs_extra_1.default.copy(source, dest, { overwrite: true });
120
- }
121
- }
122
- mergeConfigs(configs) {
123
- return configs.reduce((merged, config) => {
124
- return {
125
- ...merged,
126
- dependencies: {
127
- ...merged.dependencies,
128
- ...config.dependencies,
129
- },
130
- devDependencies: {
131
- ...merged.devDependencies,
132
- ...config.devDependencies,
133
- },
134
- scripts: {
135
- ...merged.scripts,
136
- ...config.scripts,
137
- },
138
- env: {
139
- ...merged.env,
140
- ...config.env,
141
- },
142
- };
143
- }, {});
144
- }
145
- async writePackageJson(targetDir, config) {
146
- const pkgPath = path_1.default.join(targetDir, "package.json");
147
- let pkg = {};
148
- if (await fs_extra_1.default.pathExists(pkgPath)) {
149
- pkg = await fs_extra_1.default.readJson(pkgPath);
150
- }
151
- // Merge dependencies and scripts
152
- if (config.dependencies) {
153
- pkg.dependencies = { ...pkg.dependencies, ...config.dependencies };
154
- }
155
- if (config.devDependencies) {
156
- pkg.devDependencies = { ...pkg.devDependencies, ...config.devDependencies };
157
- }
158
- if (config.scripts) {
159
- pkg.scripts = { ...pkg.scripts, ...config.scripts };
160
- }
161
- await fs_extra_1.default.writeJson(pkgPath, pkg, { spaces: 2 });
162
- }
163
- async writeEnvFile(targetDir, config) {
164
- if (!config.env || Object.keys(config.env).length === 0) {
165
- return;
166
- }
167
- const envPath = path_1.default.join(targetDir, ".env");
168
- const envExamplePath = path_1.default.join(targetDir, ".env.example");
169
- const envContent = Object.entries(config.env)
170
- .map(([key, value]) => `${key}="${value}"`)
171
- .join("\n") + "\n";
172
- // Append or create .env.example
173
- if (await fs_extra_1.default.pathExists(envExamplePath)) {
174
- const existing = await fs_extra_1.default.readFile(envExamplePath, "utf-8");
175
- if (!existing.includes(envContent)) {
176
- await fs_extra_1.default.appendFile(envExamplePath, "\n" + envContent);
177
- }
178
- }
179
- else {
180
- await fs_extra_1.default.writeFile(envExamplePath, envContent);
181
- }
182
- // Don't overwrite existing .env, but create if missing
183
- if (!(await fs_extra_1.default.pathExists(envPath))) {
184
- await fs_extra_1.default.writeFile(envPath, envContent);
185
- }
186
- }
187
- getAuthKey(framework, auth) {
188
- // Map framework + auth to specific implementation
189
- const mapping = {
190
- "nextjs-nextauth": "nextauth",
191
- "nextjs-better-auth": "better-auth-nextjs",
192
- "express-better-auth": "better-auth-express",
193
- };
194
- return mapping[`${framework}-${auth}`] || auth;
195
- }
196
- }
197
- exports.TemplateComposer = TemplateComposer;
@@ -1,13 +0,0 @@
1
- import { betterAuth } from "better-auth";
2
- import { mongodbAdapter } from "better-auth/adapters/mongodb";
3
- import { client } from "./db";
4
-
5
- export const auth = betterAuth({
6
- database: mongodbAdapter(client),
7
- emailAndPassword: {
8
- enabled: true,
9
- },
10
- });
11
-
12
- export type Session = typeof auth.$Infer.Session;
13
- export type User = typeof auth.$Infer.User;
@@ -1,15 +0,0 @@
1
- import { prismaAdapter } from "@better-auth/prisma";
2
- import { betterAuth } from "better-auth";
3
- import { prisma } from "./db";
4
-
5
- export const auth = betterAuth({
6
- database: prismaAdapter(prisma, {
7
- provider: "mongodb",
8
- }),
9
- emailAndPassword: {
10
- enabled: true,
11
- },
12
- });
13
-
14
- export type Session = typeof auth.$Infer.Session;
15
- export type User = typeof auth.$Infer.User;
@@ -1,15 +0,0 @@
1
- import { prismaAdapter } from "@better-auth/prisma";
2
- import { betterAuth } from "better-auth";
3
- import { prisma } from "./db";
4
-
5
- export const auth = betterAuth({
6
- database: prismaAdapter(prisma, {
7
- provider: "postgresql",
8
- }),
9
- emailAndPassword: {
10
- enabled: true,
11
- },
12
- });
13
-
14
- export type Session = typeof auth.$Infer.Session;
15
- export type User = typeof auth.$Infer.User;
@@ -1,16 +0,0 @@
1
- import { betterAuth } from "better-auth";
2
-
3
- export const auth = betterAuth({
4
- secret: process.env.BETTER_AUTH_SECRET!,
5
- baseURL: process.env.BETTER_AUTH_URL!,
6
-
7
- emailAndPassword: {
8
- enabled: true,
9
- },
10
-
11
- // Uncomment to add database adapter
12
- // database: {
13
- // provider: "pg", // or "mongodb", "mysql"
14
- // url: process.env.DATABASE_URL!,
15
- // },
16
- });
@@ -1,12 +0,0 @@
1
- import { Router } from "express";
2
- import { auth } from "../lib/auth";
3
-
4
- const router = Router();
5
-
6
- // Mount Better Auth handlers
7
- router.all("/auth/*", async (req, res) => {
8
- const response = await auth.handler(req);
9
- return res.status(response.status).json(response.body);
10
- });
11
-
12
- export default router;
@@ -1,72 +0,0 @@
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
- }
@@ -1,72 +0,0 @@
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,61 +0,0 @@
1
- {
2
- "name": "better-auth-express",
3
- "displayName": "Better Auth (Express)",
4
- "description": "Modern authentication with Better Auth for Express",
5
- "category": "auth",
6
- "supportedFrameworks": ["express"],
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
- }
32
- },
33
- "envVars": [
34
- {
35
- "key": "BETTER_AUTH_SECRET",
36
- "value": "",
37
- "description": "Secret key for Better Auth. Generate with: openssl rand -base64 32",
38
- "required": true
39
- },
40
- {
41
- "key": "BETTER_AUTH_URL",
42
- "value": "http://localhost:3000",
43
- "description": "Base URL of your application (change in production)",
44
- "required": true
45
- }
46
- ],
47
- "patches": [
48
- {
49
- "type": "create-file",
50
- "description": "Create Better Auth configuration",
51
- "source": "lib/auth.ts",
52
- "destination": "src/lib/auth.ts"
53
- },
54
- {
55
- "type": "create-file",
56
- "description": "Create auth routes",
57
- "source": "routes/auth.ts",
58
- "destination": "src/routes/auth.ts"
59
- }
60
- ]
61
- }
@@ -1,24 +0,0 @@
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;
@@ -1,26 +0,0 @@
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;
@@ -1,26 +0,0 @@
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,26 +0,0 @@
1
- import { prismaAdapter } from "@better-auth/prisma";
2
- import { betterAuth } from "better-auth";
3
- import { prisma } from "./db";
4
-
5
- export const auth = betterAuth({
6
- database: prismaAdapter(prisma, {
7
- provider: "postgresql", // Change to 'mongodb' if using 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;
@@ -1,72 +0,0 @@
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
- }