stackkit-cli 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 (57) hide show
  1. package/bin/stackkit.js +10 -1
  2. package/dist/commands/add.js +138 -1
  3. package/dist/types/index.d.ts +14 -2
  4. package/modules/auth/better-auth/files/lib/auth.ts +13 -0
  5. package/modules/auth/better-auth/files/schemas/prisma-schema.prisma +63 -0
  6. package/modules/auth/better-auth/module.json +54 -0
  7. package/modules/auth/clerk/module.json +115 -0
  8. package/modules/database/mongoose-mongodb/files/lib/db.ts +44 -6
  9. package/modules/database/mongoose-mongodb/files/models/User.ts +39 -0
  10. package/modules/database/mongoose-mongodb/module.json +27 -12
  11. package/modules/database/prisma/files/lib/prisma.ts +6 -0
  12. package/modules/database/prisma/files/prisma/schema.prisma +8 -0
  13. package/modules/database/prisma/files/prisma.config.ts +12 -0
  14. package/modules/database/prisma/module.json +140 -0
  15. package/package.json +1 -1
  16. package/templates/express/.env.example +2 -10
  17. package/templates/express/package.json +12 -18
  18. package/templates/express/src/app.ts +9 -29
  19. package/templates/express/src/config/env.ts +3 -14
  20. package/templates/express/src/features/auth/auth.controller.ts +48 -0
  21. package/templates/express/src/features/auth/auth.route.ts +10 -0
  22. package/templates/express/src/features/auth/auth.service.ts +21 -0
  23. package/templates/express/src/middlewares/error.middleware.ts +2 -2
  24. package/templates/express/src/server.ts +1 -1
  25. package/templates/express/template.json +1 -5
  26. package/templates/express/tsconfig.json +0 -1
  27. package/modules/auth/better-auth-express/adapters/mongoose-mongodb.ts +0 -13
  28. package/modules/auth/better-auth-express/adapters/prisma-mongodb.ts +0 -15
  29. package/modules/auth/better-auth-express/adapters/prisma-postgresql.ts +0 -15
  30. package/modules/auth/better-auth-express/files/lib/auth.ts +0 -16
  31. package/modules/auth/better-auth-express/files/routes/auth.ts +0 -12
  32. package/modules/auth/better-auth-express/files/schemas/prisma-mongodb-schema.prisma +0 -72
  33. package/modules/auth/better-auth-express/files/schemas/prisma-postgresql-schema.prisma +0 -72
  34. package/modules/auth/better-auth-express/module.json +0 -61
  35. package/modules/auth/better-auth-nextjs/adapters/mongoose-mongodb.ts +0 -24
  36. package/modules/auth/better-auth-nextjs/adapters/prisma-mongodb.ts +0 -26
  37. package/modules/auth/better-auth-nextjs/adapters/prisma-postgresql.ts +0 -26
  38. package/modules/auth/better-auth-nextjs/files/lib/auth.ts +0 -26
  39. package/modules/auth/better-auth-nextjs/files/schemas/prisma-mongodb-schema.prisma +0 -72
  40. package/modules/auth/better-auth-nextjs/files/schemas/prisma-postgresql-schema.prisma +0 -72
  41. package/modules/auth/better-auth-nextjs/module.json +0 -62
  42. package/modules/auth/better-auth-react/files/lib/auth-client.ts +0 -9
  43. package/modules/auth/better-auth-react/module.json +0 -28
  44. package/modules/auth/clerk-express/module.json +0 -34
  45. package/modules/auth/clerk-nextjs/module.json +0 -64
  46. package/modules/auth/clerk-react/module.json +0 -28
  47. package/modules/database/prisma-mongodb/files/lib/db.ts +0 -9
  48. package/modules/database/prisma-mongodb/files/prisma/schema.prisma +0 -17
  49. package/modules/database/prisma-mongodb/module.json +0 -60
  50. package/modules/database/prisma-postgresql/files/lib/db.ts +0 -9
  51. package/modules/database/prisma-postgresql/files/prisma/schema.prisma +0 -17
  52. package/modules/database/prisma-postgresql/module.json +0 -60
  53. /package/modules/auth/{better-auth-nextjs → better-auth}/files/api/auth/[...all]/route.ts +0 -0
  54. /package/modules/auth/{clerk-express/files/lib → clerk/files/express}/auth.ts +0 -0
  55. /package/modules/auth/{clerk-nextjs/files/lib → clerk/files/nextjs}/auth-provider.tsx +0 -0
  56. /package/modules/auth/{clerk-nextjs/files → clerk/files/nextjs}/middleware.ts +0 -0
  57. /package/modules/auth/{clerk-react/files/lib → clerk/files/react}/auth-provider.tsx +0 -0
@@ -0,0 +1,140 @@
1
+ {
2
+ "name": "prisma",
3
+ "displayName": "Prisma",
4
+ "description": "Prisma ORM",
5
+ "category": "database",
6
+ "provider": "prisma",
7
+ "supportedFrameworks": ["nextjs", "express"],
8
+ "dependencies": {
9
+ "common": {
10
+ "@prisma/client": "^7.2.0",
11
+ "dotenv": "^17.2.3"
12
+ },
13
+ "providers": {
14
+ "postgresql": {
15
+ "@prisma/adapter-pg": "^7.2.0",
16
+ "pg": "^8.16.3"
17
+ },
18
+ "mongodb": {
19
+ "@prisma/client": "6.19"
20
+ },
21
+ "mysql": {
22
+ "@prisma/adapter-mariadb": "^7.2.0"
23
+ },
24
+ "sqlite": {
25
+ "@prisma/adapter-better-sqlite3": "^7.2.0"
26
+ }
27
+ }
28
+ },
29
+ "devDependencies": {
30
+ "common": {
31
+ "prisma": "^7.2.0",
32
+ "tsx": "^4.21.0"
33
+ },
34
+ "providers": {
35
+ "postgresql": {
36
+ "@types/pg": "^8.16.0"
37
+ },
38
+ "mongodb": {
39
+ "prisma": "6.19"
40
+ },
41
+ "mysql": {},
42
+ "sqlite": {
43
+ "@types/better-sqlite3": "^7.6.13"
44
+ }
45
+ }
46
+ },
47
+ "envVars": {
48
+ "common": [
49
+ {
50
+ "key": "DATABASE_URL",
51
+ "value": "{{connectionString}}",
52
+ "description": "Database connection URL",
53
+ "required": true
54
+ }
55
+ ],
56
+ "providers": {
57
+ "mysql": [
58
+ {
59
+ "key": "DATABASE_HOST",
60
+ "value": "localhost",
61
+ "description": "MySQL host",
62
+ "required": true
63
+ },
64
+ {
65
+ "key": "DATABASE_USER",
66
+ "value": "",
67
+ "description": "MySQL username",
68
+ "required": true
69
+ },
70
+ {
71
+ "key": "DATABASE_PASSWORD",
72
+ "value": "",
73
+ "description": "MySQL password",
74
+ "required": true
75
+ },
76
+ {
77
+ "key": "DATABASE_NAME",
78
+ "value": "mydb",
79
+ "description": "MySQL database name",
80
+ "required": true
81
+ },
82
+ {
83
+ "key": "DATABASE_PORT",
84
+ "value": "3306",
85
+ "description": "MySQL port",
86
+ "required": false
87
+ }
88
+ ]
89
+ }
90
+ },
91
+ "frameworkPatches": {
92
+ "express": {
93
+ "tsconfig.json": {
94
+ "merge": {
95
+ "compilerOptions": {
96
+ "baseUrl": ".",
97
+ "paths": {
98
+ "@/*": ["./src/*"]
99
+ }
100
+ },
101
+ "include": ["src/**/*"],
102
+ "exclude": ["node_modules", "dist", "prisma/migrations"]
103
+ }
104
+ }
105
+ },
106
+ "nextjs": {
107
+ "tsconfig.json": {
108
+ "merge": {
109
+ "compilerOptions": {
110
+ "paths": {
111
+ "@/*": ["./*"]
112
+ }
113
+ },
114
+ "exclude": ["node_modules", ".next", "out", "prisma/migrations"]
115
+ }
116
+ }
117
+ }
118
+ },
119
+ "patches": [
120
+ {
121
+ "type": "create-file",
122
+ "description": "Create Prisma schema",
123
+ "source": "prisma/schema.prisma",
124
+ "destination": "prisma/schema.prisma"
125
+ },
126
+ {
127
+ "type": "create-file",
128
+ "description": "Create Prisma config",
129
+ "source": "prisma.config.ts",
130
+ "destination": "prisma.config.ts"
131
+ },
132
+ {
133
+ "type": "create-file",
134
+ "description": "Create Prisma client singleton",
135
+ "source": "lib/prisma.ts",
136
+ "destination": "{{lib}}/prisma.ts"
137
+ }
138
+ ],
139
+ "postInstall": ["npx prisma generate"]
140
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackkit-cli",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "CLI for StackKit - Production-ready project generator and module system",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,11 +1,3 @@
1
+ # APP CONFIGURATION
1
2
  PORT=3000
2
- NODE_ENV=development
3
- APP_URL=http://localhost:3000
4
- SITE_URL=http://localhost:5173
5
-
6
- # Proxy (set to true if running behind a proxy/load-balancer)
7
- TRUST_PROXY=false
8
-
9
- # Rate limit
10
- RATE_LIMIT_MAX=100
11
- RATE_LIMIT_WINDOW_MS=900000
3
+ NODE_ENV=development
@@ -1,12 +1,10 @@
1
1
  {
2
- "name": "my-app",
2
+ "name": "my-express-app",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "tsx watch src/server.ts",
8
- "clean": "rimraf dist",
9
- "prebuild": "npm run clean",
10
8
  "build": "tsc",
11
9
  "lint": "eslint src --ext .ts",
12
10
  "lint:fix": "eslint src --ext .ts --fix",
@@ -14,26 +12,22 @@
14
12
  "start:prod": "cross-env NODE_ENV=production node dist/server.js"
15
13
  },
16
14
  "dependencies": {
17
- "compression": "^1.7.4",
18
15
  "cors": "^2.8.5",
19
- "dotenv": "^16.4.7",
20
- "express": "^4.21.2",
21
- "express-rate-limit": "^6.7.0",
22
- "helmet": "^7.0.0",
23
- "morgan": "^1.10.0"
16
+ "dotenv": "^17.2.3",
17
+ "express": "^5.2.1",
18
+ "helmet": "^8.1.0",
19
+ "morgan": "^1.10.1"
24
20
  },
25
21
  "devDependencies": {
26
- "@types/compression": "^1.8.1",
27
- "@types/cors": "^2.8.17",
28
- "@types/express": "^4.17.21",
29
- "@types/morgan": "^1.9.4",
30
- "@types/node": "^22.10.5",
22
+ "@types/cors": "^2.8.19",
23
+ "@types/express": "^5.0.6",
24
+ "@types/morgan": "^1.9.10",
25
+ "@types/node": "^25.0.6",
31
26
  "@typescript-eslint/eslint-plugin": "^8.52.0",
32
27
  "@typescript-eslint/parser": "^8.52.0",
33
- "cross-env": "^7.0.3",
28
+ "cross-env": "^10.1.0",
34
29
  "eslint": "^9.39.2",
35
- "rimraf": "^5.0.0",
36
- "tsx": "^4.19.2",
37
- "typescript": "^5.7.2"
30
+ "tsx": "^4.21.0",
31
+ "typescript": "^5.9.3"
38
32
  }
39
33
  }
@@ -1,54 +1,31 @@
1
- import compression from "compression";
2
1
  import cors from "cors";
3
2
  import express, { Application, NextFunction, Request, Response } from "express";
4
- import rateLimit from "express-rate-limit";
5
3
  import helmet from "helmet";
6
4
  import morgan from "morgan";
7
5
  import { env } from "./config/env";
6
+ import { authRoutes } from "./features/auth/auth.route";
8
7
  import { errorHandler } from "./middlewares/error.middleware";
9
8
 
10
9
  // app initialization
11
10
  const app: Application = express();
12
11
  app.use(express.json());
13
12
 
14
- // trust proxy when behind reverse proxy (like Heroku, Vercel, Load Balancers)
15
- if (env.app.trust_proxy) {
16
- app.set("trust proxy", 1);
17
- }
18
-
19
13
  // security headers
20
14
  app.use(helmet());
21
15
 
22
- // response compression
23
- app.use(compression());
24
-
25
- // rate limiting
26
- const limiter = rateLimit({
27
- windowMs: env.app.rateLimit.windowMs,
28
- max: env.app.rateLimit.max,
29
- standardHeaders: true,
30
- legacyHeaders: false,
31
- });
32
- app.use(limiter);
33
-
34
16
  // logging
35
- if (env.node.isProduction) {
17
+ if (env.isProduction) {
36
18
  app.use(morgan("combined"));
37
19
  } else {
38
20
  app.use(morgan("dev"));
39
21
  }
40
22
 
41
23
  // cors configuration
42
- app.use(
43
- cors({
44
- origin: [env.app.site_url],
45
- credentials: true,
46
- }),
47
- );
24
+ app.use(cors());
48
25
 
49
26
  // Home page route
50
- app.get("/", (req: Request, res: Response) => {
51
- res.json({
27
+ app.get("/", (_req: Request, res: Response) => {
28
+ res.status(200).json({
52
29
  title: "Welcome to your Express app",
53
30
  description:
54
31
  "Built with StackKit - A production-ready Express template with TypeScript, security, and best practices.",
@@ -57,8 +34,11 @@ app.get("/", (req: Request, res: Response) => {
57
34
  });
58
35
  });
59
36
 
37
+ // routes
38
+ app.use("/api/auth", authRoutes);
39
+
60
40
  // unhandled routes
61
- app.use((req: Request, res: Response, next: NextFunction) => {
41
+ app.use((req: Request, _res: Response, next: NextFunction) => {
62
42
  const error: any = new Error(`Can't find ${req.originalUrl} on this server!`);
63
43
  error.status = 404;
64
44
 
@@ -4,20 +4,9 @@ import path from "path";
4
4
  dotenv.config({ path: path.join(process.cwd(), ".env") });
5
5
 
6
6
  const env = {
7
- app: {
8
- port: Number(process.env.PORT) || 3000,
9
- url: process.env.APP_URL || "http://localhost:3000",
10
- site_url: process.env.SITE_URL || "http://localhost:5173",
11
- trust_proxy: (process.env.TRUST_PROXY || "false") === "true",
12
- rateLimit: {
13
- max: Number(process.env.RATE_LIMIT_MAX) || 100,
14
- windowMs: Number(process.env.RATE_LIMIT_WINDOW_MS) || 15 * 60 * 1000,
15
- },
16
- },
17
- node: {
18
- env: process.env.NODE_ENV || "development",
19
- isProduction: (process.env.NODE_ENV || "development") === "production",
20
- },
7
+ port: Number(process.env.PORT) || 3000,
8
+ node_env: process.env.NODE_ENV || "development",
9
+ isProduction: (process.env.NODE_ENV || "development") === "production",
21
10
  };
22
11
 
23
12
  export { env };
@@ -0,0 +1,48 @@
1
+ import { NextFunction, Request, Response } from "express";
2
+ import { authServices } from "./auth.service";
3
+
4
+ const signup = async (req: Request, res: Response, next: NextFunction) => {
5
+ try {
6
+ const result = await authServices.signup(req.body);
7
+
8
+ res.status(201).json({
9
+ success: true,
10
+ message: "User registered successfully",
11
+ data: result,
12
+ });
13
+ } catch (error) {
14
+ next(error);
15
+ }
16
+ };
17
+
18
+ const signin = async (req: Request, res: Response, next: NextFunction) => {
19
+ try {
20
+ const { email, password } = req.body;
21
+
22
+ const result = await authServices.signin(email, password);
23
+
24
+ if (!result) {
25
+ res.status(401).json({
26
+ success: false,
27
+ message: "Invalid email or password",
28
+ });
29
+ return;
30
+ }
31
+
32
+ res.status(200).json({
33
+ success: true,
34
+ message: "Login successful",
35
+ data: {
36
+ token: result.token,
37
+ user: result.user,
38
+ },
39
+ });
40
+ } catch (error) {
41
+ next(error);
42
+ }
43
+ };
44
+
45
+ export const authController = {
46
+ signup,
47
+ signin,
48
+ };
@@ -0,0 +1,10 @@
1
+ import { Router } from "express";
2
+ import { authController } from "./auth.controller";
3
+
4
+ const router = Router();
5
+
6
+ // routes
7
+ router.post("/signup", authController.signup);
8
+ router.post("/signin", authController.signin);
9
+
10
+ export const authRoutes = router;
@@ -0,0 +1,21 @@
1
+ // @ts-nocheck
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3
+
4
+ const signup = async (payload: Record<string, unknown>) => {
5
+ // your logic here
6
+ };
7
+
8
+ const signin = async (
9
+ email: string,
10
+ password: string,
11
+ ): Promise<{ token: string; user: any } | null> => {
12
+ // your logic here
13
+ return null;
14
+ };
15
+
16
+ export const authServices = {
17
+ signup,
18
+ signin,
19
+ };
20
+
21
+ export type { User };
@@ -1,7 +1,7 @@
1
1
  import { NextFunction, Request, Response } from "express";
2
2
  import { env } from "../config/env";
3
3
 
4
- export const errorHandler = (err: any, req: Request, res: Response, next: NextFunction) => {
4
+ export const errorHandler = (err: any, _req: Request, res: Response, _: NextFunction) => {
5
5
  const statusCode = err.status || 500;
6
6
  const errorMessage = err?.message || "Internal server error!";
7
7
 
@@ -10,7 +10,7 @@ export const errorHandler = (err: any, req: Request, res: Response, next: NextFu
10
10
  message: errorMessage,
11
11
  };
12
12
 
13
- if (!env.node.isProduction) {
13
+ if (!env.isProduction) {
14
14
  payload.errors = err?.stack || err;
15
15
  }
16
16
 
@@ -1,7 +1,7 @@
1
1
  import app from "./app";
2
2
  import { env } from "./config/env";
3
3
 
4
- const port = env.app.port;
4
+ const port = env.port;
5
5
 
6
6
  app.listen(port, () => {
7
7
  console.log(`Server is running on http://localhost:${port}`);
@@ -3,11 +3,9 @@
3
3
  "displayName": "Express.js",
4
4
  "framework": "express",
5
5
  "description": "Express.js REST API with TypeScript",
6
- "files": ["src/", ".env.example", ".gitignore", "package.json", "tsconfig.json"],
6
+ "files": ["src/", ".gitignore", "package.json", "tsconfig.json", ".env.example"],
7
7
  "scripts": {
8
8
  "dev": "tsx watch src/server.ts",
9
- "clean": "rimraf dist",
10
- "prebuild": "npm run clean",
11
9
  "build": "tsc",
12
10
  "lint": "eslint src --ext .ts",
13
11
  "lint:fix": "eslint src --ext .ts --fix",
@@ -16,8 +14,6 @@
16
14
  },
17
15
  "jsScripts": {
18
16
  "dev": "tsx --watch src/server.js",
19
- "clean": "rimraf dist",
20
- "prebuild": "npm run clean",
21
17
  "build": "echo 'No build step for JavaScript'",
22
18
  "lint": "eslint src --ext .js",
23
19
  "lint:fix": "eslint src --ext .js --fix",
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "rootDir": "./src",
4
3
  "outDir": "./dist",
5
4
  "module": "ESNext",
6
5
  "moduleResolution": "node",
@@ -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
- }