stackkit-cli 0.2.0 → 0.3.1

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 (94) hide show
  1. package/README.md +6 -0
  2. package/dist/commands/add.js +12 -4
  3. package/dist/commands/add.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/types/index.d.ts +2 -1
  7. package/dist/types/index.d.ts.map +1 -1
  8. package/dist/utils/code-inject.js +1 -1
  9. package/dist/utils/code-inject.js.map +1 -1
  10. package/dist/utils/detect.d.ts.map +1 -1
  11. package/dist/utils/detect.js +45 -16
  12. package/dist/utils/detect.js.map +1 -1
  13. package/dist/utils/env-editor.d.ts.map +1 -1
  14. package/dist/utils/env-editor.js +2 -2
  15. package/dist/utils/env-editor.js.map +1 -1
  16. package/dist/utils/files.js +1 -1
  17. package/dist/utils/files.js.map +1 -1
  18. package/modules/auth/authjs-express/files/lib/auth.ts +40 -0
  19. package/modules/auth/authjs-express/files/routes/auth.ts +12 -0
  20. package/modules/auth/authjs-express/module.json +39 -0
  21. package/modules/auth/authjs-nextjs/files/api/auth/[...nextauth]/route.ts +3 -0
  22. package/modules/auth/authjs-nextjs/files/lib/auth.ts +43 -0
  23. package/modules/auth/authjs-nextjs/module.json +38 -0
  24. package/modules/auth/better-auth-express/files/lib/auth.ts +16 -0
  25. package/modules/auth/better-auth-express/files/routes/auth.ts +12 -0
  26. package/modules/auth/better-auth-express/module.json +38 -0
  27. package/modules/auth/better-auth-nextjs/files/api/auth/[...all]/route.ts +3 -0
  28. package/modules/auth/better-auth-nextjs/files/lib/auth.ts +18 -0
  29. package/modules/auth/better-auth-nextjs/module.json +38 -0
  30. package/modules/auth/better-auth-react/files/lib/auth-client.ts +9 -0
  31. package/modules/auth/better-auth-react/module.json +26 -0
  32. package/modules/database/prisma-mongodb/files/lib/db.ts +9 -0
  33. package/modules/database/prisma-mongodb/files/prisma/schema.prisma +17 -0
  34. package/modules/database/prisma-mongodb/module.json +36 -0
  35. package/modules/database/prisma-postgresql/files/lib/db.ts +9 -0
  36. package/modules/database/prisma-postgresql/files/prisma/schema.prisma +17 -0
  37. package/modules/database/prisma-postgresql/module.json +36 -0
  38. package/package.json +3 -3
  39. package/templates/auth/authjs-express/config.json +20 -0
  40. package/templates/auth/authjs-express/files/lib/auth.ts +43 -0
  41. package/templates/auth/authjs-express/files/routes/auth.ts +12 -0
  42. package/templates/auth/authjs-express/lib/auth.ts +43 -0
  43. package/templates/auth/authjs-express/module.json +39 -0
  44. package/templates/auth/authjs-express/routes/auth.ts +12 -0
  45. package/templates/auth/authjs-nextjs/app/api/auth/[...nextauth]/route.ts +3 -0
  46. package/templates/auth/authjs-nextjs/config.json +19 -0
  47. package/templates/auth/authjs-nextjs/files/api/auth/[...nextauth]/route.ts +3 -0
  48. package/templates/auth/authjs-nextjs/files/lib/auth.ts +45 -0
  49. package/templates/auth/authjs-nextjs/lib/auth.ts +45 -0
  50. package/templates/auth/authjs-nextjs/module.json +38 -0
  51. package/templates/auth/better-auth-express/config.json +18 -0
  52. package/templates/auth/better-auth-express/src/lib/auth.ts +12 -0
  53. package/templates/auth/better-auth-express/src/routes/auth.ts +10 -0
  54. package/templates/auth/better-auth-nextjs/app/api/auth/[...all]/route.ts +4 -0
  55. package/templates/auth/better-auth-nextjs/config.json +18 -0
  56. package/templates/auth/better-auth-nextjs/lib/auth.ts +14 -0
  57. package/templates/auth/better-auth-react/config.json +15 -0
  58. package/templates/auth/better-auth-react/files/lib/auth-client.ts +9 -0
  59. package/templates/auth/better-auth-react/lib/auth-client.ts +9 -0
  60. package/templates/auth/better-auth-react/module.json +26 -0
  61. package/templates/auth/nextauth/app/api/auth/[...nextauth]/route.ts +3 -0
  62. package/templates/auth/nextauth/config.json +18 -0
  63. package/templates/auth/nextauth/lib/auth.ts +31 -0
  64. package/templates/bases/express-base/.env.example +2 -0
  65. package/templates/bases/express-base/package.json +23 -0
  66. package/templates/bases/express-base/src/index.ts +27 -0
  67. package/templates/bases/express-base/template.json +7 -0
  68. package/templates/bases/express-base/tsconfig.json +17 -0
  69. package/templates/bases/nextjs-base/.eslintrc.json +3 -0
  70. package/templates/bases/nextjs-base/app/globals.css +3 -0
  71. package/templates/{next-prisma-postgres-shadcn → bases/nextjs-base}/app/layout.tsx +3 -6
  72. package/templates/bases/nextjs-base/app/page.tsx +8 -0
  73. package/templates/{next-prisma-postgres-shadcn → bases/nextjs-base}/next.config.ts +1 -3
  74. package/templates/bases/nextjs-base/package.json +24 -0
  75. package/templates/bases/nextjs-base/template.json +7 -0
  76. package/templates/{next-prisma-postgres-shadcn → bases/nextjs-base}/tsconfig.json +1 -6
  77. package/templates/databases/prisma-mongodb/config.json +21 -0
  78. package/templates/{next-prisma-postgres-shadcn → databases/prisma-mongodb}/lib/db.ts +2 -3
  79. package/templates/databases/prisma-mongodb/prisma/schema.prisma +16 -0
  80. package/templates/databases/prisma-postgresql/config.json +22 -0
  81. package/templates/databases/prisma-postgresql/lib/db.ts +13 -0
  82. package/templates/databases/prisma-postgresql/prisma/schema.prisma +16 -0
  83. package/templates/next-prisma-postgres-shadcn/.env.example +0 -5
  84. package/templates/next-prisma-postgres-shadcn/.eslintrc.json +0 -7
  85. package/templates/next-prisma-postgres-shadcn/.prettierrc +0 -8
  86. package/templates/next-prisma-postgres-shadcn/README.md +0 -85
  87. package/templates/next-prisma-postgres-shadcn/app/api/health/route.ts +0 -25
  88. package/templates/next-prisma-postgres-shadcn/app/globals.css +0 -1
  89. package/templates/next-prisma-postgres-shadcn/app/page.tsx +0 -29
  90. package/templates/next-prisma-postgres-shadcn/lib/env.ts +0 -15
  91. package/templates/next-prisma-postgres-shadcn/package.json +0 -32
  92. package/templates/next-prisma-postgres-shadcn/prisma/schema.prisma +0 -20
  93. package/templates/next-prisma-postgres-shadcn/public/.gitkeep +0 -1
  94. package/templates/next-prisma-postgres-shadcn/template.json +0 -18
@@ -0,0 +1,18 @@
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
+ // Add your authentication providers here
8
+ // Example: email/password, OAuth (Google, GitHub, etc.)
9
+ emailAndPassword: {
10
+ enabled: true,
11
+ },
12
+
13
+ // Uncomment to add database adapter
14
+ // database: {
15
+ // provider: "pg", // or "mongodb", "mysql"
16
+ // url: process.env.DATABASE_URL!,
17
+ // },
18
+ });
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "auth",
3
+ "displayName": "Better Auth (Next.js)",
4
+ "description": "Modern authentication with Better Auth for Next.js",
5
+ "category": "auth",
6
+ "supportedFrameworks": ["nextjs"],
7
+ "dependencies": {
8
+ "better-auth": "^1.0.0"
9
+ },
10
+ "envVars": [
11
+ {
12
+ "key": "BETTER_AUTH_SECRET",
13
+ "value": "",
14
+ "description": "Secret key for Better Auth. Generate with: openssl rand -base64 32",
15
+ "required": true
16
+ },
17
+ {
18
+ "key": "BETTER_AUTH_URL",
19
+ "value": "http://localhost:3000",
20
+ "description": "Base URL of your application (change in production)",
21
+ "required": true
22
+ }
23
+ ],
24
+ "patches": [
25
+ {
26
+ "type": "create-file",
27
+ "description": "Create Better Auth configuration",
28
+ "source": "lib/auth.ts",
29
+ "destination": "{{lib}}/auth.ts"
30
+ },
31
+ {
32
+ "type": "create-file",
33
+ "description": "Create Better Auth API route",
34
+ "source": "api/auth/[...all]/route.ts",
35
+ "destination": "{{router}}/api/auth/[...all]/route.ts"
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1,9 @@
1
+ import { createAuthClient } from 'better-auth/react';
2
+
3
+ export const authClient = createAuthClient({
4
+ /** The base URL of the server (optional if you're using the same domain) */
5
+ baseURL: import.meta.env.VITE_AUTH_URL || 'http://localhost:3000',
6
+ });
7
+
8
+ // Export specific methods for convenience
9
+ export const { signIn, signUp, signOut, useSession } = authClient;
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "auth",
3
+ "displayName": "Better Auth (React)",
4
+ "description": "Client-side authentication with Better Auth for React",
5
+ "category": "auth",
6
+ "supportedFrameworks": ["react", "react-vite"],
7
+ "dependencies": {
8
+ "better-auth": "^1.0.0"
9
+ },
10
+ "envVars": [
11
+ {
12
+ "key": "VITE_AUTH_URL",
13
+ "value": "http://localhost:3000",
14
+ "description": "Base URL of your auth server (optional if same domain)",
15
+ "required": false
16
+ }
17
+ ],
18
+ "patches": [
19
+ {
20
+ "type": "create-file",
21
+ "description": "Create Better Auth client configuration",
22
+ "source": "lib/auth-client.ts",
23
+ "destination": "src/lib/auth-client.ts"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,9 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+
3
+ const globalForPrisma = globalThis as unknown as {
4
+ prisma: PrismaClient | undefined;
5
+ };
6
+
7
+ export const db = globalForPrisma.prisma ?? new PrismaClient();
8
+
9
+ if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;
@@ -0,0 +1,17 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "mongodb"
7
+ url = env("DATABASE_URL")
8
+ }
9
+
10
+ // Example model - customize as needed
11
+ model User {
12
+ id String @id @default(auto()) @map("_id") @db.ObjectId
13
+ email String @unique
14
+ name String?
15
+ createdAt DateTime @default(now())
16
+ updatedAt DateTime @updatedAt
17
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "database",
3
+ "displayName": "Prisma + MongoDB",
4
+ "description": "Add Prisma ORM with MongoDB database",
5
+ "category": "database",
6
+ "supportedFrameworks": ["nextjs", "express"],
7
+ "dependencies": {
8
+ "@prisma/client": "^6.1.0"
9
+ },
10
+ "devDependencies": {
11
+ "prisma": "^6.1.0"
12
+ },
13
+ "envVars": [
14
+ {
15
+ "key": "DATABASE_URL",
16
+ "value": "mongodb://localhost:27017/mydb",
17
+ "description": "MongoDB connection URL",
18
+ "required": true
19
+ }
20
+ ],
21
+ "patches": [
22
+ {
23
+ "type": "create-file",
24
+ "description": "Create Prisma schema for MongoDB",
25
+ "source": "prisma/schema.prisma",
26
+ "destination": "prisma/schema.prisma"
27
+ },
28
+ {
29
+ "type": "create-file",
30
+ "description": "Create Prisma client singleton",
31
+ "source": "lib/db.ts",
32
+ "destination": "{{lib}}/db.ts"
33
+ }
34
+ ],
35
+ "postInstall": ["npx prisma generate"]
36
+ }
@@ -0,0 +1,9 @@
1
+ import { PrismaClient } from '@prisma/client';
2
+
3
+ const globalForPrisma = globalThis as unknown as {
4
+ prisma: PrismaClient | undefined;
5
+ };
6
+
7
+ export const db = globalForPrisma.prisma ?? new PrismaClient();
8
+
9
+ if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;
@@ -0,0 +1,17 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "postgresql"
7
+ url = env("DATABASE_URL")
8
+ }
9
+
10
+ // Example model - customize as needed
11
+ model User {
12
+ id String @id @default(cuid())
13
+ email String @unique
14
+ name String?
15
+ createdAt DateTime @default(now())
16
+ updatedAt DateTime @updatedAt
17
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "database",
3
+ "displayName": "Prisma + PostgreSQL",
4
+ "description": "Add Prisma ORM with PostgreSQL database",
5
+ "category": "database",
6
+ "supportedFrameworks": ["nextjs", "express"],
7
+ "dependencies": {
8
+ "@prisma/client": "^6.1.0"
9
+ },
10
+ "devDependencies": {
11
+ "prisma": "^6.1.0"
12
+ },
13
+ "envVars": [
14
+ {
15
+ "key": "DATABASE_URL",
16
+ "value": "postgresql://user:password@localhost:5432/mydb?schema=public",
17
+ "description": "PostgreSQL database connection URL",
18
+ "required": true
19
+ }
20
+ ],
21
+ "patches": [
22
+ {
23
+ "type": "create-file",
24
+ "description": "Create Prisma schema",
25
+ "source": "prisma/schema.prisma",
26
+ "destination": "prisma/schema.prisma"
27
+ },
28
+ {
29
+ "type": "create-file",
30
+ "description": "Create Prisma client singleton",
31
+ "source": "lib/db.ts",
32
+ "destination": "{{lib}}/db.ts"
33
+ }
34
+ ],
35
+ "postInstall": ["npx prisma generate"]
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackkit-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "CLI for StackKit - Production-ready project generator and module system",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "scripts": {
20
20
  "dev": "tsc --watch",
21
- "build": "tsc",
21
+ "build": "tsc && cp -r ../../templates . && cp -r ../../modules .",
22
22
  "clean": "rm -rf dist templates modules",
23
23
  "typecheck": "tsc --noEmit",
24
24
  "lint": "eslint src --ext .ts",
25
- "prepublishOnly": "npm run build && cp -r ../../templates . && cp -r ../../modules ."
25
+ "prepublishOnly": "npm run build"
26
26
  },
27
27
  "keywords": [
28
28
  "cli",
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "authjs-express",
3
+ "displayName": "Auth.js (Express)",
4
+ "description": "Authentication with Auth.js for Express",
5
+ "frameworks": ["express"],
6
+ "dependencies": {
7
+ "@auth/express": "^0.7.6",
8
+ "@auth/core": "^0.37.4"
9
+ },
10
+ "envVars": {
11
+ "AUTH_SECRET": {
12
+ "value": "",
13
+ "description": "Secret for encrypting tokens. Generate with: openssl rand -base64 32"
14
+ },
15
+ "AUTH_TRUST_HOST": {
16
+ "value": "true",
17
+ "description": "Trust the host header (required for Express)"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,43 @@
1
+ import { Auth } from '@auth/core';
2
+ import GitHub from '@auth/core/providers/github';
3
+ import Google from '@auth/core/providers/google';
4
+ import Credentials from '@auth/core/providers/credentials';
5
+
6
+ export const authConfig = {
7
+ secret: process.env.AUTH_SECRET,
8
+ trustHost: true,
9
+ providers: [
10
+ // GitHub OAuth Provider
11
+ // Uncomment and add GITHUB_ID and GITHUB_SECRET to .env
12
+ // GitHub({
13
+ // clientId: process.env.GITHUB_ID!,
14
+ // clientSecret: process.env.GITHUB_SECRET!,
15
+ // }),
16
+
17
+ // Google OAuth Provider
18
+ // Uncomment and add GOOGLE_ID and GOOGLE_SECRET to .env
19
+ // Google({
20
+ // clientId: process.env.GOOGLE_ID!,
21
+ // clientSecret: process.env.GOOGLE_SECRET!,
22
+ // }),
23
+
24
+ // Credentials Provider (email/password)
25
+ Credentials({
26
+ credentials: {
27
+ email: { label: 'Email', type: 'email' },
28
+ password: { label: 'Password', type: 'password' },
29
+ },
30
+ authorize: async (credentials) => {
31
+ // Add your own authentication logic here
32
+ if (credentials?.email === 'demo@example.com' && credentials?.password === 'demo') {
33
+ return {
34
+ id: '1',
35
+ name: 'Demo User',
36
+ email: 'demo@example.com',
37
+ };
38
+ }
39
+ return null;
40
+ },
41
+ }),
42
+ ],
43
+ };
@@ -0,0 +1,12 @@
1
+ import { Router } from 'express';
2
+ import { Auth } from '@auth/core';
3
+ import { authConfig } from '../lib/auth';
4
+
5
+ const router = Router();
6
+
7
+ router.all('/auth/*', async (req, res) => {
8
+ const response = await Auth(req, authConfig);
9
+ return res.status(response.status).json(response.body);
10
+ });
11
+
12
+ export default router;
@@ -0,0 +1,43 @@
1
+ import { Auth } from '@auth/core';
2
+ import GitHub from '@auth/core/providers/github';
3
+ import Google from '@auth/core/providers/google';
4
+ import Credentials from '@auth/core/providers/credentials';
5
+
6
+ export const authConfig = {
7
+ secret: process.env.AUTH_SECRET,
8
+ trustHost: true,
9
+ providers: [
10
+ // GitHub OAuth Provider
11
+ // Uncomment and add GITHUB_ID and GITHUB_SECRET to .env
12
+ // GitHub({
13
+ // clientId: process.env.GITHUB_ID!,
14
+ // clientSecret: process.env.GITHUB_SECRET!,
15
+ // }),
16
+
17
+ // Google OAuth Provider
18
+ // Uncomment and add GOOGLE_ID and GOOGLE_SECRET to .env
19
+ // Google({
20
+ // clientId: process.env.GOOGLE_ID!,
21
+ // clientSecret: process.env.GOOGLE_SECRET!,
22
+ // }),
23
+
24
+ // Credentials Provider (email/password)
25
+ Credentials({
26
+ credentials: {
27
+ email: { label: 'Email', type: 'email' },
28
+ password: { label: 'Password', type: 'password' },
29
+ },
30
+ authorize: async (credentials) => {
31
+ // Add your own authentication logic here
32
+ if (credentials?.email === 'demo@example.com' && credentials?.password === 'demo') {
33
+ return {
34
+ id: '1',
35
+ name: 'Demo User',
36
+ email: 'demo@example.com',
37
+ };
38
+ }
39
+ return null;
40
+ },
41
+ }),
42
+ ],
43
+ };
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "auth",
3
+ "displayName": "Auth.js (Express)",
4
+ "description": "Authentication with Auth.js for Express",
5
+ "category": "auth",
6
+ "supportedFrameworks": ["express"],
7
+ "dependencies": {
8
+ "@auth/express": "^0.7.6",
9
+ "@auth/core": "^0.37.4"
10
+ },
11
+ "envVars": [
12
+ {
13
+ "key": "AUTH_SECRET",
14
+ "value": "",
15
+ "description": "Secret for encrypting tokens. Generate with: openssl rand -base64 32",
16
+ "required": true
17
+ },
18
+ {
19
+ "key": "AUTH_TRUST_HOST",
20
+ "value": "true",
21
+ "description": "Trust the host header (required for Express)",
22
+ "required": true
23
+ }
24
+ ],
25
+ "patches": [
26
+ {
27
+ "type": "create-file",
28
+ "description": "Create Auth.js configuration",
29
+ "source": "lib/auth.ts",
30
+ "destination": "src/lib/auth.ts"
31
+ },
32
+ {
33
+ "type": "create-file",
34
+ "description": "Create auth routes",
35
+ "source": "routes/auth.ts",
36
+ "destination": "src/routes/auth.ts"
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,12 @@
1
+ import { Router } from 'express';
2
+ import { Auth } from '@auth/core';
3
+ import { authConfig } from '../lib/auth';
4
+
5
+ const router = Router();
6
+
7
+ router.all('/auth/*', async (req, res) => {
8
+ const response = await Auth(req, authConfig);
9
+ return res.status(response.status).json(response.body);
10
+ });
11
+
12
+ export default router;
@@ -0,0 +1,3 @@
1
+ import { handlers } from '@/lib/auth';
2
+
3
+ export const { GET, POST } = handlers;
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "authjs-nextjs",
3
+ "displayName": "Auth.js v5 (Next.js)",
4
+ "description": "Modern authentication with Auth.js v5 (NextAuth successor)",
5
+ "frameworks": ["nextjs"],
6
+ "dependencies": {
7
+ "next-auth": "^5.0.0-beta.25"
8
+ },
9
+ "envVars": {
10
+ "AUTH_SECRET": {
11
+ "value": "",
12
+ "description": "Secret for encrypting tokens. Generate with: openssl rand -base64 32"
13
+ },
14
+ "AUTH_URL": {
15
+ "value": "http://localhost:3000",
16
+ "description": "Canonical URL of your site (change in production)"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ import { handlers } from '@/lib/auth';
2
+
3
+ export const { GET, POST } = handlers;
@@ -0,0 +1,45 @@
1
+ import NextAuth from 'next-auth';
2
+ import GitHub from 'next-auth/providers/github';
3
+ import Google from 'next-auth/providers/google';
4
+ import Credentials from 'next-auth/providers/credentials';
5
+
6
+ export const { handlers, signIn, signOut, auth } = NextAuth({
7
+ providers: [
8
+ // GitHub OAuth Provider
9
+ // Uncomment and add GITHUB_ID and GITHUB_SECRET to .env
10
+ // GitHub({
11
+ // clientId: process.env.GITHUB_ID!,
12
+ // clientSecret: process.env.GITHUB_SECRET!,
13
+ // }),
14
+
15
+ // Google OAuth Provider
16
+ // Uncomment and add GOOGLE_ID and GOOGLE_SECRET to .env
17
+ // Google({
18
+ // clientId: process.env.GOOGLE_ID!,
19
+ // clientSecret: process.env.GOOGLE_SECRET!,
20
+ // }),
21
+
22
+ // Credentials Provider (email/password)
23
+ Credentials({
24
+ credentials: {
25
+ email: { label: 'Email', type: 'email' },
26
+ password: { label: 'Password', type: 'password' },
27
+ },
28
+ authorize: async (credentials) => {
29
+ // Add your own authentication logic here
30
+ // This is just a demo - DO NOT use in production
31
+ if (credentials?.email === 'demo@example.com' && credentials?.password === 'demo') {
32
+ return {
33
+ id: '1',
34
+ name: 'Demo User',
35
+ email: 'demo@example.com',
36
+ };
37
+ }
38
+ return null;
39
+ },
40
+ }),
41
+ ],
42
+ pages: {
43
+ signIn: '/auth/signin',
44
+ },
45
+ });
@@ -0,0 +1,45 @@
1
+ import NextAuth from 'next-auth';
2
+ import GitHub from 'next-auth/providers/github';
3
+ import Google from 'next-auth/providers/google';
4
+ import Credentials from 'next-auth/providers/credentials';
5
+
6
+ export const { handlers, signIn, signOut, auth } = NextAuth({
7
+ providers: [
8
+ // GitHub OAuth Provider
9
+ // Uncomment and add GITHUB_ID and GITHUB_SECRET to .env
10
+ // GitHub({
11
+ // clientId: process.env.GITHUB_ID!,
12
+ // clientSecret: process.env.GITHUB_SECRET!,
13
+ // }),
14
+
15
+ // Google OAuth Provider
16
+ // Uncomment and add GOOGLE_ID and GOOGLE_SECRET to .env
17
+ // Google({
18
+ // clientId: process.env.GOOGLE_ID!,
19
+ // clientSecret: process.env.GOOGLE_SECRET!,
20
+ // }),
21
+
22
+ // Credentials Provider (email/password)
23
+ Credentials({
24
+ credentials: {
25
+ email: { label: 'Email', type: 'email' },
26
+ password: { label: 'Password', type: 'password' },
27
+ },
28
+ authorize: async (credentials) => {
29
+ // Add your own authentication logic here
30
+ // This is just a demo - DO NOT use in production
31
+ if (credentials?.email === 'demo@example.com' && credentials?.password === 'demo') {
32
+ return {
33
+ id: '1',
34
+ name: 'Demo User',
35
+ email: 'demo@example.com',
36
+ };
37
+ }
38
+ return null;
39
+ },
40
+ }),
41
+ ],
42
+ pages: {
43
+ signIn: '/auth/signin',
44
+ },
45
+ });
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "auth",
3
+ "displayName": "Auth.js v5 (Next.js)",
4
+ "description": "Modern authentication with Auth.js v5 (NextAuth successor)",
5
+ "category": "auth",
6
+ "supportedFrameworks": ["nextjs"],
7
+ "dependencies": {
8
+ "next-auth": "^5.0.0-beta.25"
9
+ },
10
+ "envVars": [
11
+ {
12
+ "key": "AUTH_SECRET",
13
+ "value": "",
14
+ "description": "Secret for encrypting tokens. Generate with: openssl rand -base64 32",
15
+ "required": true
16
+ },
17
+ {
18
+ "key": "AUTH_URL",
19
+ "value": "http://localhost:3000",
20
+ "description": "Canonical URL of your site (change in production)",
21
+ "required": false
22
+ }
23
+ ],
24
+ "patches": [
25
+ {
26
+ "type": "create-file",
27
+ "description": "Create Auth.js configuration",
28
+ "source": "lib/auth.ts",
29
+ "destination": "{{lib}}/auth.ts"
30
+ },
31
+ {
32
+ "type": "create-file",
33
+ "description": "Create Auth.js API route",
34
+ "source": "api/auth/[...nextauth]/route.ts",
35
+ "destination": "{{router}}/api/auth/[...nextauth]/route.ts"
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "better-auth-express",
3
+ "displayName": "Better Auth (Express)",
4
+ "auth": "better-auth",
5
+ "compatibleWith": {
6
+ "frameworks": ["express"],
7
+ "databases": ["prisma-postgresql", "prisma-mongodb"]
8
+ },
9
+ "dependencies": {
10
+ "better-auth": "^1.1.4",
11
+ "@better-auth/prisma": "^1.1.4"
12
+ },
13
+ "env": {
14
+ "BETTER_AUTH_SECRET": "your-secret-here",
15
+ "BETTER_AUTH_URL": "http://localhost:3000"
16
+ },
17
+ "files": ["src/lib/auth.ts", "src/routes/auth.ts"]
18
+ }
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,10 @@
1
+ import { Router } from 'express';
2
+ import { auth } from '../lib/auth';
3
+
4
+ const router = Router();
5
+
6
+ router.all('*', async (req, res) => {
7
+ return auth.handler(req, res);
8
+ });
9
+
10
+ export default router;
@@ -0,0 +1,4 @@
1
+ import { auth } from '@/lib/auth';
2
+ import { toNextJsHandler } from 'better-auth/next-js';
3
+
4
+ export const { GET, POST } = toNextJsHandler(auth);
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "better-auth-nextjs",
3
+ "displayName": "Better Auth (Next.js)",
4
+ "auth": "better-auth",
5
+ "compatibleWith": {
6
+ "frameworks": ["nextjs"],
7
+ "databases": ["prisma-postgresql", "prisma-mongodb"]
8
+ },
9
+ "dependencies": {
10
+ "better-auth": "^1.1.4",
11
+ "@better-auth/prisma": "^1.1.4"
12
+ },
13
+ "env": {
14
+ "BETTER_AUTH_SECRET": "your-secret-here",
15
+ "BETTER_AUTH_URL": "http://localhost:3000"
16
+ },
17
+ "files": ["lib/auth.ts", "app/api/auth/[...all]/route.ts"]
18
+ }