stackkit-cli 0.3.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.
- package/README.md +6 -0
- package/dist/commands/add.js +12 -4
- package/dist/commands/add.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/code-inject.js +1 -1
- package/dist/utils/code-inject.js.map +1 -1
- package/dist/utils/detect.d.ts.map +1 -1
- package/dist/utils/detect.js +45 -16
- package/dist/utils/detect.js.map +1 -1
- package/dist/utils/env-editor.d.ts.map +1 -1
- package/dist/utils/env-editor.js +2 -2
- package/dist/utils/env-editor.js.map +1 -1
- package/dist/utils/files.js +1 -1
- package/dist/utils/files.js.map +1 -1
- package/modules/auth/authjs-express/files/lib/auth.ts +40 -0
- package/modules/auth/authjs-express/files/routes/auth.ts +12 -0
- package/modules/auth/authjs-express/module.json +39 -0
- package/modules/auth/authjs-nextjs/files/api/auth/[...nextauth]/route.ts +3 -0
- package/modules/auth/authjs-nextjs/files/lib/auth.ts +43 -0
- package/modules/auth/authjs-nextjs/module.json +38 -0
- package/modules/auth/better-auth-express/files/lib/auth.ts +16 -0
- package/modules/auth/better-auth-express/files/routes/auth.ts +12 -0
- package/modules/auth/better-auth-express/module.json +38 -0
- package/modules/auth/better-auth-nextjs/files/api/auth/[...all]/route.ts +3 -0
- package/modules/auth/better-auth-nextjs/files/lib/auth.ts +18 -0
- package/modules/auth/better-auth-nextjs/module.json +38 -0
- package/modules/auth/better-auth-react/files/lib/auth-client.ts +9 -0
- package/modules/auth/better-auth-react/module.json +26 -0
- package/modules/database/prisma-mongodb/files/lib/db.ts +9 -0
- package/modules/database/prisma-mongodb/files/prisma/schema.prisma +17 -0
- package/modules/database/prisma-mongodb/module.json +36 -0
- package/modules/database/prisma-postgresql/files/lib/db.ts +9 -0
- package/modules/database/prisma-postgresql/files/prisma/schema.prisma +17 -0
- package/modules/database/prisma-postgresql/module.json +36 -0
- package/package.json +4 -4
- package/templates/auth/authjs-express/config.json +20 -0
- package/templates/auth/authjs-express/files/lib/auth.ts +43 -0
- package/templates/auth/authjs-express/files/routes/auth.ts +12 -0
- package/templates/auth/authjs-express/lib/auth.ts +43 -0
- package/templates/auth/authjs-express/module.json +39 -0
- package/templates/auth/authjs-express/routes/auth.ts +12 -0
- package/templates/auth/authjs-nextjs/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/auth/authjs-nextjs/config.json +19 -0
- package/templates/auth/authjs-nextjs/files/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/auth/authjs-nextjs/files/lib/auth.ts +45 -0
- package/templates/auth/authjs-nextjs/lib/auth.ts +45 -0
- package/templates/auth/authjs-nextjs/module.json +38 -0
- package/templates/auth/better-auth-react/config.json +15 -0
- package/templates/auth/better-auth-react/files/lib/auth-client.ts +9 -0
- package/templates/auth/better-auth-react/lib/auth-client.ts +9 -0
- package/templates/auth/better-auth-react/module.json +26 -0
- package/templates/next-prisma-postgres-shadcn/.env.example +0 -5
- package/templates/next-prisma-postgres-shadcn/.eslintrc.json +0 -7
- package/templates/next-prisma-postgres-shadcn/.prettierrc +0 -8
- package/templates/next-prisma-postgres-shadcn/README.md +0 -85
- package/templates/next-prisma-postgres-shadcn/app/api/health/route.ts +0 -25
- package/templates/next-prisma-postgres-shadcn/app/globals.css +0 -1
- package/templates/next-prisma-postgres-shadcn/app/layout.tsx +0 -22
- package/templates/next-prisma-postgres-shadcn/app/page.tsx +0 -29
- package/templates/next-prisma-postgres-shadcn/lib/db.ts +0 -14
- package/templates/next-prisma-postgres-shadcn/lib/env.ts +0 -15
- package/templates/next-prisma-postgres-shadcn/next.config.ts +0 -7
- package/templates/next-prisma-postgres-shadcn/package.json +0 -32
- package/templates/next-prisma-postgres-shadcn/prisma/schema.prisma +0 -20
- package/templates/next-prisma-postgres-shadcn/public/.gitkeep +0 -1
- package/templates/next-prisma-postgres-shadcn/template.json +0 -18
- package/templates/next-prisma-postgres-shadcn/tsconfig.json +0 -32
|
@@ -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.3.
|
|
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
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|
|
28
28
|
"cli",
|
|
@@ -55,4 +55,4 @@
|
|
|
55
55
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
56
56
|
"typescript": "^5.3.3"
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|
|
@@ -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,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,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,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "better-auth-react",
|
|
3
|
+
"displayName": "Better Auth (React)",
|
|
4
|
+
"description": "Client-side authentication with Better Auth for React",
|
|
5
|
+
"frameworks": ["react", "react-vite"],
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"better-auth": "^1.0.0"
|
|
8
|
+
},
|
|
9
|
+
"envVars": {
|
|
10
|
+
"VITE_AUTH_URL": {
|
|
11
|
+
"value": "http://localhost:3000",
|
|
12
|
+
"description": "Base URL of your auth server (optional if same domain)"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -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,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
|
+
}
|