create-stackkit-app 0.3.0 → 0.4.0
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 +12 -94
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lib/create-project.d.ts +0 -1
- package/dist/lib/create-project.js +124 -67
- package/dist/lib/template-composer.d.ts +0 -1
- package/dist/lib/template-composer.js +0 -2
- 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/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/{templates/auth/better-auth-nextjs/app → modules/auth/better-auth-nextjs/files}/api/auth/[...all]/route.ts +1 -0
- package/modules/auth/better-auth-nextjs/files/lib/auth.ts +26 -0
- package/modules/auth/better-auth-nextjs/module.json +41 -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/auth/clerk-express/files/lib/auth.ts +7 -0
- package/modules/auth/clerk-express/module.json +19 -0
- package/modules/auth/clerk-nextjs/files/lib/auth-provider.tsx +5 -0
- package/modules/auth/clerk-nextjs/files/middleware.ts +9 -0
- package/modules/auth/clerk-nextjs/module.json +27 -0
- package/modules/auth/clerk-react/files/lib/auth-provider.tsx +15 -0
- package/modules/auth/clerk-react/module.json +18 -0
- package/modules/auth/nextauth/files/app-router/api/auth/[...nextauth]/route.ts +6 -0
- package/modules/auth/nextauth/files/lib/auth.ts +82 -0
- package/modules/auth/nextauth/files/pages-router/api/auth/[...nextauth].ts +4 -0
- package/modules/auth/nextauth/module.json +50 -0
- package/modules/database/drizzle-postgresql/files/drizzle.config.ts +10 -0
- package/modules/database/drizzle-postgresql/files/lib/db.ts +7 -0
- package/modules/database/drizzle-postgresql/files/lib/schema.ts +8 -0
- package/modules/database/drizzle-postgresql/module.json +34 -0
- package/modules/database/mongoose-mongodb/files/lib/db.ts +40 -0
- package/modules/database/mongoose-mongodb/module.json +17 -0
- package/{templates/databases/prisma-mongodb → modules/database/prisma-mongodb/files}/lib/db.ts +2 -6
- package/{templates/databases/prisma-mongodb → modules/database/prisma-mongodb/files}/prisma/schema.prisma +1 -0
- package/modules/database/prisma-mongodb/module.json +36 -0
- package/{templates/databases/prisma-postgresql → modules/database/prisma-postgresql/files}/lib/db.ts +2 -6
- package/{templates/databases/prisma-postgresql → modules/database/prisma-postgresql/files}/prisma/schema.prisma +1 -0
- package/modules/database/prisma-postgresql/module.json +36 -0
- package/package.json +7 -5
- package/templates/bases/nextjs-base/README.md +36 -0
- package/templates/bases/nextjs-base/app/favicon.ico +0 -0
- package/templates/bases/nextjs-base/app/globals.css +26 -3
- package/templates/bases/nextjs-base/app/layout.tsx +21 -6
- package/templates/bases/nextjs-base/app/page.tsx +61 -4
- package/templates/bases/nextjs-base/eslint.config.mjs +18 -0
- package/templates/bases/nextjs-base/next.config.ts +4 -2
- package/templates/bases/nextjs-base/package-lock.json +6538 -0
- package/templates/bases/nextjs-base/package.json +12 -10
- package/templates/bases/nextjs-base/postcss.config.mjs +7 -0
- package/templates/bases/nextjs-base/public/file.svg +1 -0
- package/templates/bases/nextjs-base/public/globe.svg +1 -0
- package/templates/bases/nextjs-base/public/next.svg +1 -0
- package/templates/bases/nextjs-base/public/vercel.svg +1 -0
- package/templates/bases/nextjs-base/public/window.svg +1 -0
- package/templates/bases/nextjs-base/template.json +12 -1
- package/templates/bases/nextjs-base/tsconfig.json +9 -2
- package/templates/bases/react-vite-base/index.html +13 -0
- package/templates/bases/react-vite-base/package.json +27 -0
- package/templates/bases/react-vite-base/src/App.css +14 -0
- package/templates/bases/react-vite-base/src/App.tsx +23 -0
- package/templates/bases/react-vite-base/src/index.css +68 -0
- package/templates/bases/react-vite-base/src/main.tsx +10 -0
- package/templates/bases/react-vite-base/src/vite-env.d.ts +1 -0
- package/templates/bases/react-vite-base/template.json +5 -0
- package/templates/bases/react-vite-base/tsconfig.json +21 -0
- package/templates/bases/react-vite-base/vite.config.ts +7 -0
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/create-project.d.ts.map +0 -1
- package/dist/lib/create-project.js.map +0 -1
- package/dist/lib/template-composer.d.ts.map +0 -1
- package/dist/lib/template-composer.js.map +0 -1
- package/templates/auth/better-auth-express/config.json +0 -18
- package/templates/auth/better-auth-express/src/lib/auth.ts +0 -12
- package/templates/auth/better-auth-express/src/routes/auth.ts +0 -10
- package/templates/auth/better-auth-nextjs/config.json +0 -18
- package/templates/auth/better-auth-nextjs/lib/auth.ts +0 -14
- package/templates/auth/nextauth/config.json +0 -18
- package/templates/auth/nextauth/lib/auth.ts +0 -31
- package/templates/bases/nextjs-base/.eslintrc.json +0 -3
- package/templates/databases/prisma-mongodb/config.json +0 -21
- package/templates/databases/prisma-postgresql/config.json +0 -22
- /package/{templates/auth/nextauth/app → modules/auth/authjs-nextjs/files}/api/auth/[...nextauth]/route.ts +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
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;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "auth",
|
|
3
|
+
"displayName": "Better Auth (Next.js)",
|
|
4
|
+
"description": "Modern authentication with Better Auth for Next.js App Router",
|
|
5
|
+
"category": "auth",
|
|
6
|
+
"provider": "better-auth",
|
|
7
|
+
"supportedFrameworks": ["nextjs"],
|
|
8
|
+
"compatibleDatabases": ["prisma-postgresql", "prisma-mongodb"],
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"better-auth": "^1.1.4",
|
|
11
|
+
"@better-auth/prisma": "^1.1.4"
|
|
12
|
+
},
|
|
13
|
+
"envVars": [
|
|
14
|
+
{
|
|
15
|
+
"key": "BETTER_AUTH_SECRET",
|
|
16
|
+
"value": "",
|
|
17
|
+
"description": "Secret key for Better Auth. Generate with: openssl rand -base64 32",
|
|
18
|
+
"required": true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"key": "BETTER_AUTH_URL",
|
|
22
|
+
"value": "http://localhost:3000",
|
|
23
|
+
"description": "Base URL of your application (change in production)",
|
|
24
|
+
"required": true
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"patches": [
|
|
28
|
+
{
|
|
29
|
+
"type": "create-file",
|
|
30
|
+
"description": "Create Better Auth configuration",
|
|
31
|
+
"source": "lib/auth.ts",
|
|
32
|
+
"destination": "{{lib}}/auth.ts"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "create-file",
|
|
36
|
+
"description": "Create Better Auth API route handler",
|
|
37
|
+
"source": "app/api/auth/[...all]/route.ts",
|
|
38
|
+
"destination": "{{router}}/api/auth/[...all]/route.ts"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -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,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clerk-express",
|
|
3
|
+
"description": "Clerk Authentication for Express.js",
|
|
4
|
+
"category": "auth",
|
|
5
|
+
"framework": "express",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@clerk/express": "^1.4.5"
|
|
8
|
+
},
|
|
9
|
+
"env": {
|
|
10
|
+
"CLERK_PUBLISHABLE_KEY": "pk_test_your_key_here",
|
|
11
|
+
"CLERK_SECRET_KEY": "sk_test_your_key_here"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"source": "files/lib/auth.ts",
|
|
16
|
+
"destination": "lib/auth.ts"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clerk-nextjs",
|
|
3
|
+
"description": "Clerk Authentication for Next.js",
|
|
4
|
+
"category": "auth",
|
|
5
|
+
"framework": "nextjs",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@clerk/nextjs": "^6.10.2"
|
|
8
|
+
},
|
|
9
|
+
"env": {
|
|
10
|
+
"NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY": "pk_test_your_key_here",
|
|
11
|
+
"CLERK_SECRET_KEY": "sk_test_your_key_here",
|
|
12
|
+
"NEXT_PUBLIC_CLERK_SIGN_IN_URL": "/sign-in",
|
|
13
|
+
"NEXT_PUBLIC_CLERK_SIGN_UP_URL": "/sign-up",
|
|
14
|
+
"NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL": "/",
|
|
15
|
+
"NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL": "/"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
{
|
|
19
|
+
"source": "files/lib/auth-provider.tsx",
|
|
20
|
+
"destination": "lib/auth-provider.tsx"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"source": "files/middleware.ts",
|
|
24
|
+
"destination": "middleware.ts"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClerkProvider } from '@clerk/clerk-react';
|
|
2
|
+
|
|
3
|
+
const publishableKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
|
|
4
|
+
|
|
5
|
+
if (!publishableKey) {
|
|
6
|
+
throw new Error('Missing Publishable Key');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|
10
|
+
return (
|
|
11
|
+
<ClerkProvider publishableKey={publishableKey} afterSignOutUrl="/">
|
|
12
|
+
{children}
|
|
13
|
+
</ClerkProvider>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clerk-react",
|
|
3
|
+
"description": "Clerk Authentication for React",
|
|
4
|
+
"category": "auth",
|
|
5
|
+
"framework": "react-vite",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@clerk/clerk-react": "^5.19.2"
|
|
8
|
+
},
|
|
9
|
+
"env": {
|
|
10
|
+
"VITE_CLERK_PUBLISHABLE_KEY": "pk_test_your_key_here"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"source": "files/lib/auth-provider.tsx",
|
|
15
|
+
"destination": "lib/auth-provider.tsx"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AuthOptions } from 'next-auth';
|
|
2
|
+
import CredentialsProvider from 'next-auth/providers/credentials';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* NextAuth.js Configuration
|
|
6
|
+
*
|
|
7
|
+
* Configure authentication providers and options here.
|
|
8
|
+
* See: https://next-auth.js.org/configuration/options
|
|
9
|
+
*/
|
|
10
|
+
export const authOptions: AuthOptions = {
|
|
11
|
+
providers: [
|
|
12
|
+
// GitHub OAuth Provider
|
|
13
|
+
// Uncomment and add GITHUB_ID and GITHUB_SECRET to .env
|
|
14
|
+
// GithubProvider({
|
|
15
|
+
// clientId: process.env.GITHUB_ID!,
|
|
16
|
+
// clientSecret: process.env.GITHUB_SECRET!,
|
|
17
|
+
// }),
|
|
18
|
+
|
|
19
|
+
// Google OAuth Provider
|
|
20
|
+
// Uncomment and add GOOGLE_ID and GOOGLE_SECRET to .env
|
|
21
|
+
// GoogleProvider({
|
|
22
|
+
// clientId: process.env.GOOGLE_ID!,
|
|
23
|
+
// clientSecret: process.env.GOOGLE_SECRET!,
|
|
24
|
+
// }),
|
|
25
|
+
|
|
26
|
+
// Credentials Provider (email/password)
|
|
27
|
+
// Replace with your own authentication logic
|
|
28
|
+
CredentialsProvider({
|
|
29
|
+
name: 'Credentials',
|
|
30
|
+
credentials: {
|
|
31
|
+
email: { label: 'Email', type: 'email', placeholder: 'user@example.com' },
|
|
32
|
+
password: { label: 'Password', type: 'password' },
|
|
33
|
+
},
|
|
34
|
+
async authorize(credentials) {
|
|
35
|
+
// Add your own authentication logic here
|
|
36
|
+
// This is just a demo - DO NOT use in production
|
|
37
|
+
if (credentials?.email === 'demo@example.com' && credentials?.password === 'demo') {
|
|
38
|
+
return {
|
|
39
|
+
id: '1',
|
|
40
|
+
name: 'Demo User',
|
|
41
|
+
email: 'demo@example.com',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
// Database adapter (optional)
|
|
50
|
+
// Uncomment to persist sessions in database
|
|
51
|
+
// adapter: PrismaAdapter(prisma),
|
|
52
|
+
|
|
53
|
+
session: {
|
|
54
|
+
strategy: 'jwt',
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
pages: {
|
|
58
|
+
signIn: '/auth/signin',
|
|
59
|
+
// signOut: '/auth/signout',
|
|
60
|
+
// error: '/auth/error',
|
|
61
|
+
// verifyRequest: '/auth/verify-request',
|
|
62
|
+
// newUser: '/auth/new-user'
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
callbacks: {
|
|
66
|
+
async jwt({ token, user }) {
|
|
67
|
+
if (user) {
|
|
68
|
+
token.id = user.id;
|
|
69
|
+
}
|
|
70
|
+
return token;
|
|
71
|
+
},
|
|
72
|
+
async session({ session, token }) {
|
|
73
|
+
if (session.user) {
|
|
74
|
+
session.user.id = token.id as string;
|
|
75
|
+
}
|
|
76
|
+
return session;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// Enable debug messages in development
|
|
81
|
+
debug: process.env.NODE_ENV === 'development',
|
|
82
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "auth",
|
|
3
|
+
"displayName": "NextAuth.js Authentication",
|
|
4
|
+
"description": "Add authentication with NextAuth.js (supports multiple providers)",
|
|
5
|
+
"category": "auth",
|
|
6
|
+
"supportedFrameworks": ["nextjs"],
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"next-auth": "^4.24.5"
|
|
9
|
+
},
|
|
10
|
+
"envVars": [
|
|
11
|
+
{
|
|
12
|
+
"key": "NEXTAUTH_URL",
|
|
13
|
+
"value": "http://localhost:3000",
|
|
14
|
+
"description": "The URL of your application (change in production)",
|
|
15
|
+
"required": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"key": "NEXTAUTH_SECRET",
|
|
19
|
+
"value": "",
|
|
20
|
+
"description": "Secret for encrypting tokens. Generate with: openssl rand -base64 32",
|
|
21
|
+
"required": true
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"patches": [
|
|
25
|
+
{
|
|
26
|
+
"type": "create-file",
|
|
27
|
+
"description": "Create NextAuth API route for App Router",
|
|
28
|
+
"source": "app-router/api/auth/[...nextauth]/route.ts",
|
|
29
|
+
"destination": "{{router}}/api/auth/[...nextauth]/route.ts",
|
|
30
|
+
"condition": {
|
|
31
|
+
"router": "app"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "create-file",
|
|
36
|
+
"description": "Create NextAuth API route for Pages Router",
|
|
37
|
+
"source": "pages-router/api/auth/[...nextauth].ts",
|
|
38
|
+
"destination": "{{router}}/api/auth/[...nextauth].ts",
|
|
39
|
+
"condition": {
|
|
40
|
+
"router": "pages"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "create-file",
|
|
45
|
+
"description": "Create auth configuration",
|
|
46
|
+
"source": "lib/auth.ts",
|
|
47
|
+
"destination": "{{lib}}/auth.ts"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
export const users = pgTable('users', {
|
|
4
|
+
id: serial('id').primaryKey(),
|
|
5
|
+
name: text('name').notNull(),
|
|
6
|
+
email: text('email').notNull().unique(),
|
|
7
|
+
createdAt: timestamp('created_at').defaultNow(),
|
|
8
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "drizzle-postgresql",
|
|
3
|
+
"description": "Drizzle ORM with PostgreSQL",
|
|
4
|
+
"category": "database",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"drizzle-orm": "^0.36.4",
|
|
7
|
+
"postgres": "^3.4.5"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"drizzle-kit": "^0.28.1"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"db:generate": "drizzle-kit generate",
|
|
14
|
+
"db:migrate": "drizzle-kit migrate",
|
|
15
|
+
"db:studio": "drizzle-kit studio"
|
|
16
|
+
},
|
|
17
|
+
"env": {
|
|
18
|
+
"DATABASE_URL": "postgresql://postgres:password@localhost:5432/myapp"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
{
|
|
22
|
+
"source": "files/lib/db.ts",
|
|
23
|
+
"destination": "lib/db.ts"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"source": "files/lib/schema.ts",
|
|
27
|
+
"destination": "lib/schema.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"source": "files/drizzle.config.ts",
|
|
31
|
+
"destination": "drizzle.config.ts"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/myapp';
|
|
4
|
+
|
|
5
|
+
if (!MONGODB_URI) {
|
|
6
|
+
throw new Error('Please define the MONGODB_URI environment variable');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let cached = global.mongoose;
|
|
10
|
+
|
|
11
|
+
if (!cached) {
|
|
12
|
+
cached = global.mongoose = { conn: null, promise: null };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function connectDB() {
|
|
16
|
+
if (cached.conn) {
|
|
17
|
+
return cached.conn;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!cached.promise) {
|
|
21
|
+
const opts = {
|
|
22
|
+
bufferCommands: false,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
cached.promise = mongoose.connect(MONGODB_URI, opts).then((mongoose) => {
|
|
26
|
+
return mongoose;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
cached.conn = await cached.promise;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
cached.promise = null;
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return cached.conn;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default connectDB;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mongoose-mongodb",
|
|
3
|
+
"description": "Mongoose ODM for MongoDB",
|
|
4
|
+
"category": "database",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"mongoose": "^8.8.4"
|
|
7
|
+
},
|
|
8
|
+
"env": {
|
|
9
|
+
"MONGODB_URI": "mongodb://localhost:27017/myapp"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"source": "files/lib/db.ts",
|
|
14
|
+
"destination": "lib/db.ts"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
package/{templates/databases/prisma-mongodb → modules/database/prisma-mongodb/files}/lib/db.ts
RENAMED
|
@@ -4,10 +4,6 @@ const globalForPrisma = globalThis as unknown as {
|
|
|
4
4
|
prisma: PrismaClient | undefined;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export const prisma
|
|
8
|
-
globalForPrisma.prisma ??
|
|
9
|
-
new PrismaClient({
|
|
10
|
-
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
|
11
|
-
});
|
|
7
|
+
export const db = globalForPrisma.prisma ?? new PrismaClient();
|
|
12
8
|
|
|
13
|
-
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma =
|
|
9
|
+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;
|
|
@@ -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
|
+
}
|
package/{templates/databases/prisma-postgresql → modules/database/prisma-postgresql/files}/lib/db.ts
RENAMED
|
@@ -4,10 +4,6 @@ const globalForPrisma = globalThis as unknown as {
|
|
|
4
4
|
prisma: PrismaClient | undefined;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export const prisma
|
|
8
|
-
globalForPrisma.prisma ??
|
|
9
|
-
new PrismaClient({
|
|
10
|
-
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
|
11
|
-
});
|
|
7
|
+
export const db = globalForPrisma.prisma ?? new PrismaClient();
|
|
12
8
|
|
|
13
|
-
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma =
|
|
9
|
+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;
|
|
@@ -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": "create-stackkit-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Create a new StackKit project with modular composition",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"bin",
|
|
13
|
-
"templates"
|
|
13
|
+
"templates",
|
|
14
|
+
"modules"
|
|
14
15
|
],
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
|
@@ -23,10 +24,11 @@
|
|
|
23
24
|
},
|
|
24
25
|
"scripts": {
|
|
25
26
|
"dev": "tsc --watch",
|
|
26
|
-
"build": "tsc",
|
|
27
|
-
"
|
|
27
|
+
"build": "npm run clean && tsc && npm run copy-assets",
|
|
28
|
+
"copy-assets": "cp -r ../../templates . && cp -r ../../modules .",
|
|
29
|
+
"clean": "rm -rf dist templates modules",
|
|
28
30
|
"typecheck": "tsc --noEmit",
|
|
29
|
-
"prepublishOnly": "npm run build
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
30
32
|
},
|
|
31
33
|
"keywords": [
|
|
32
34
|
"create",
|