stackkit 0.3.1 → 0.3.3

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.
@@ -1,91 +1,24 @@
1
1
  <!doctype html>
2
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
2
+ <html lang="en">
3
3
 
4
4
  <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
+ <meta charset="UTF-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
8
- <title>
9
- <%= appName || "Your App" %> - Continue with Google
10
- </title>
7
+ <title>Continue Sign-in</title>
11
8
  </head>
12
9
 
13
- <body style="margin:0; padding:0; background-color:#f3f4f6;">
14
- <div style="display:none; max-height:0; overflow:hidden; opacity:0; color:transparent;">
15
- Continue your Google sign-in securely.
16
- </div>
17
- <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0"
18
- style="background-color:#f3f4f6; padding:24px 12px;">
19
- <tr>
20
- <td align="center">
21
- <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0"
22
- style="max-width:600px; background:#ffffff; border:1px solid #e5e7eb; border-radius:12px; overflow:hidden;">
23
- <tr>
24
- <td style="padding:28px 24px 16px 24px; font-family:Arial, Helvetica, sans-serif; color:#111827;">
25
- <h1 style="margin:0; font-size:22px; line-height:30px; font-weight:700;">Continue with
26
- Google</h1>
27
- <p style="margin:14px 0 0; font-size:15px; line-height:24px; color:#374151;">
28
- Hi <%= userName || "there" %>,
29
- </p>
30
- <p style="margin:10px 0 0; font-size:15px; line-height:24px; color:#374151;">
31
- We received a request to continue authentication with Google for your <strong>
32
- <%= appName || "account" %>
33
- </strong>.
34
- </p>
35
- </td>
36
- </tr>
10
+ <body style="font-family: Arial, Helvetica, sans-serif; padding: 24px;">
11
+ <p>Redirecting to <%= provider %> login...</p>
37
12
 
38
- <tr>
39
- <td style="padding:0 24px 24px 24px; font-family:Arial, Helvetica, sans-serif;">
40
- <table role="presentation" cellspacing="0" cellpadding="0" border="0">
41
- <tr>
42
- <td align="center" bgcolor="#111827" style="border-radius:8px;">
43
- <a href="<%= redirectUrl %>" target="_blank"
44
- style="display:inline-block; padding:12px 22px; font-size:15px; line-height:20px; font-weight:600; color:#ffffff; text-decoration:none;">
45
- Continue Sign-in
46
- </a>
47
- </td>
48
- </tr>
49
- </table>
13
+ <form id="social-login-form" method="POST" action="<%= signInEndpoint %>">
14
+ <input type="hidden" name="provider" value="<%= provider %>" />
15
+ <input type="hidden" name="callbackURL" value="<%= callbackURL %>" />
16
+ <button type="submit">Continue</button>
17
+ </form>
50
18
 
51
- <p
52
- style="margin:14px 0 0; font-size:13px; line-height:20px; color:#6b7280; word-break:break-word;">
53
- Button not working? Copy and paste this URL into your browser:<br />
54
- <a href="<%= redirectUrl %>" target="_blank"
55
- style="color:#2563eb; text-decoration:underline;">
56
- <%= redirectUrl %>
57
- </a>
58
- </p>
59
- </td>
60
- </tr>
61
-
62
- <tr>
63
- <td style="padding:0 24px 24px 24px; font-family:Arial, Helvetica, sans-serif; color:#4b5563;">
64
- <p style="margin:0; font-size:14px; line-height:22px;">
65
- If you didn’t request this, you can safely ignore this email. No changes will be made
66
- unless you continue.
67
- </p>
68
- </td>
69
- </tr>
70
-
71
- <tr>
72
- <td
73
- style="padding:16px 24px 24px 24px; border-top:1px solid #e5e7eb; font-family:Arial, Helvetica, sans-serif; color:#6b7280;">
74
- <p style="margin:0; font-size:12px; line-height:18px;">
75
- Need help? Contact us at
76
- <a href="mailto:<%= supportEmail || " support@example.com" %>" style="color:#2563eb;
77
- text-decoration:underline;"><%= supportEmail || "support@example.com" %></a>.
78
- </p>
79
- <p style="margin:6px 0 0; font-size:12px; line-height:18px;">
80
- © <%= year || new Date().getFullYear() %>
81
- <%= appName || "Your App" %>. All rights reserved.
82
- </p>
83
- </td>
84
- </tr>
85
- </table>
86
- </td>
87
- </tr>
88
- </table>
89
- </body>
19
+ <script>
20
+ document.getElementById("social-login-form")?.submit();
21
+ </script>
22
+ </body>
90
23
 
91
24
  </html>
@@ -1,3 +1,5 @@
1
+ import { Role } from "@prisma/client";
2
+
1
3
  declare global {
2
4
  namespace Express {
3
5
  interface Request {
@@ -5,7 +7,7 @@ declare global {
5
7
  id: string;
6
8
  name: string;
7
9
  email: string;
8
- role: string;
10
+ role: Role;
9
11
  };
10
12
  }
11
13
  }
@@ -8,9 +8,12 @@ dotenv.config({ path: path.join(process.cwd(), ".env") });
8
8
  {{/if}}
9
9
 
10
10
  interface EnvConfig {
11
- APP_URL?: string;
11
+ APP_URL: string;
12
+ {{#if framework == "nextjs"}}
13
+ API_URL: string;
14
+ {{/if}}
12
15
  DATABASE_URL: string;
13
- FRONTEND_URL?: string;
16
+ FRONTEND_URL: string;
14
17
  BETTER_AUTH_URL: string;
15
18
  BETTER_AUTH_SECRET: string;
16
19
  GOOGLE_CLIENT_ID: string;
@@ -40,6 +43,9 @@ interface EnvConfig {
40
43
  const loadEnvVars = (): EnvConfig => {
41
44
  const requiredEnvVars = [
42
45
  "APP_URL",
46
+ {{#if framework == "nextjs"}}
47
+ "API_URL",
48
+ {{/if}}
43
49
  "DATABASE_URL",
44
50
  "FRONTEND_URL",
45
51
  "BETTER_AUTH_URL",
@@ -83,6 +89,9 @@ const loadEnvVars = (): EnvConfig => {
83
89
 
84
90
  return {
85
91
  APP_URL: process.env.APP_URL as string,
92
+ {{#if framework == "nextjs"}}
93
+ API_URL: process.env.API_URL as string,
94
+ {{/if}}
86
95
  DATABASE_URL: process.env.DATABASE_URL as string,
87
96
  FRONTEND_URL: process.env.FRONTEND_URL as string,
88
97
  BETTER_AUTH_URL: process.env.BETTER_AUTH_URL as string,
@@ -9,7 +9,7 @@ import { prismaAdapter } from "better-auth/adapters/prisma";
9
9
  {{/if}}
10
10
  {{#if combo == "prisma:nextjs"}}
11
11
  import { Role, UserStatus } from "@prisma/client";
12
- import { sendEmail } from "../service/email/email-service";
12
+ import { sendEmail } from "@/lib/utils/email";
13
13
  import { prisma } from "../database/prisma";
14
14
  import { envVars } from "@/lib/env";
15
15
  import { prismaAdapter } from "better-auth/adapters/prisma";
@@ -48,7 +48,10 @@ export const auth = betterAuth({
48
48
  baseURL: envVars.BETTER_AUTH_URL,
49
49
  secret: envVars.BETTER_AUTH_SECRET,
50
50
  trustedOrigins: [
51
- envVars.FRONTEND_URL || envVars.BETTER_AUTH_URL || "http://localhost:3000",
51
+ envVars.APP_URL!,
52
+ envVars.FRONTEND_URL!,
53
+ envVars.BETTER_AUTH_URL!,
54
+ "http://localhost:3000",
52
55
  ],
53
56
  emailAndPassword: {
54
57
  enabled: true,
@@ -69,15 +69,3 @@ model Verification {
69
69
  @@index([identifier])
70
70
  @@map("verification")
71
71
  }
72
-
73
- enum Role {
74
- SUPER_ADMIN
75
- ADMIN
76
- USER
77
- }
78
-
79
- enum UserStatus {
80
- ACTIVE
81
- BLOCKED
82
- DELETED
83
- }
@@ -0,0 +1,11 @@
1
+ enum Role {
2
+ SUPER_ADMIN
3
+ ADMIN
4
+ USER
5
+ }
6
+
7
+ enum UserStatus {
8
+ ACTIVE
9
+ BLOCKED
10
+ DELETED
11
+ }
@@ -65,6 +65,10 @@ export const sendEmail = async ({
65
65
  })),
66
66
  });
67
67
  } catch {
68
- throw new AppError(status.INTERNAL_SERVER_ERROR, "Failed to send email");
68
+ {{#if framework == "express"}}
69
+ throw new AppError(status.INTERNAL_SERVER_ERROR, `Failed to send email to ${to}`);
70
+ {{else}}
71
+ throw new Error(`Failed to send email to ${to}`);
72
+ {{/if}}
69
73
  }
70
74
  };
@@ -222,15 +222,10 @@
222
222
  "condition": { "framework": "react" }
223
223
  },
224
224
  {
225
- "type": "patch-file",
226
- "destination": "prisma/schema.prisma",
227
- "condition": { "database": "prisma" },
228
- "operations": [
229
- {
230
- "type": "add-to-bottom",
231
- "source": "shared/prisma/schema.prisma"
232
- }
233
- ]
225
+ "type": "create-file",
226
+ "source": "shared/prisma/*",
227
+ "destination": "prisma/*",
228
+ "condition": { "database": "prisma" }
234
229
  },
235
230
  {
236
231
  "type": "add-dependency",
@@ -1,5 +1,5 @@
1
- import { PrismaClient } from "@prisma/client";
2
1
  import 'dotenv/config';
2
+ import { PrismaClient } from "@prisma/client";
3
3
 
4
4
  const globalForPrisma = globalThis as unknown as {
5
5
  prisma: PrismaClient | undefined
@@ -1,7 +1,7 @@
1
1
  generator client {
2
- provider = "prisma-client-js"
2
+ provider = "prisma-client-js"
3
3
  }
4
4
 
5
5
  datasource db {
6
- provider = "{{prismaProvider}}"
6
+ provider = "{{prismaProvider}}"
7
7
  }
@@ -9,7 +9,7 @@ import { defineConfig } from "prisma/config";
9
9
  {{/switch}}
10
10
 
11
11
  export default defineConfig({
12
- schema: "prisma/schema.prisma",
12
+ schema: "./prisma",
13
13
  migrations: {
14
14
  path: "prisma/migrations",
15
15
  },
@@ -34,23 +34,23 @@
34
34
  {
35
35
  "type": "add-script",
36
36
  "scripts": {
37
- "db:generate": "npx prisma generate",
38
- "db:push": "npx prisma db push",
39
- "db:seed": "tsx prisma/seed.ts",
40
- "db:migrate": "npx prisma migrate dev",
41
- "db:studio": "npx prisma studio"
37
+ "generate": "prisma generate",
38
+ "push": "prisma db push",
39
+ "seed": "tsx prisma/seed.ts",
40
+ "migrate": "prisma migrate dev",
41
+ "studio": "prisma studio"
42
42
  }
43
43
  },
44
44
  {
45
45
  "type": "add-dependency",
46
46
  "condition": { "prismaProvider": "postgresql" },
47
47
  "dependencies": {
48
- "@prisma/client": "^7.2.0",
48
+ "@prisma/client": "^7.4.2",
49
49
  "@prisma/adapter-pg": "^7.0.0",
50
50
  "pg": "^8.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "prisma": "^7.2.0"
53
+ "prisma": "^7.4.2"
54
54
  }
55
55
  },
56
56
  {
@@ -64,12 +64,12 @@
64
64
  "type": "add-dependency",
65
65
  "condition": { "prismaProvider": "mysql" },
66
66
  "dependencies": {
67
- "@prisma/client": "^7.2.0",
67
+ "@prisma/client": "^7.4.2",
68
68
  "@prisma/adapter-mariadb": "^7.0.0",
69
69
  "mysql2": "^3.0.0"
70
70
  },
71
71
  "devDependencies": {
72
- "prisma": "^7.2.0"
72
+ "prisma": "^7.4.2"
73
73
  }
74
74
  },
75
75
  {
@@ -83,12 +83,12 @@
83
83
  "type": "add-dependency",
84
84
  "condition": { "prismaProvider": "sqlite" },
85
85
  "dependencies": {
86
- "@prisma/client": "^7.2.0",
86
+ "@prisma/client": "^7.4.2",
87
87
  "@prisma/adapter-better-sqlite3": "^7.0.0",
88
88
  "better-sqlite3": "^9.0.0"
89
89
  },
90
90
  "devDependencies": {
91
- "prisma": "^7.2.0"
91
+ "prisma": "^7.4.2"
92
92
  }
93
93
  },
94
94
  {
@@ -102,10 +102,10 @@
102
102
  "type": "add-dependency",
103
103
  "condition": { "prismaProvider": "mongodb" },
104
104
  "dependencies": {
105
- "@prisma/client": "^6.19.0"
105
+ "@prisma/client": "^7.4.2"
106
106
  },
107
107
  "devDependencies": {
108
- "prisma": "^6.19.0"
108
+ "prisma": "^7.4.2"
109
109
  }
110
110
  },
111
111
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackkit",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Production-ready CLI to create and extend JavaScript or TypeScript apps with modular stacks.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -35,21 +35,6 @@ npm run dev
35
35
  - `npm run start` - Start production server
36
36
  - `npm run lint` - Run linter
37
37
 
38
- ## Project Structure
39
-
40
- ```
41
- app/
42
- ├── globals.css # Global styles
43
- ├── layout.tsx # Root layout
44
- ├── page.tsx # Home page
45
- └── api/ # API routes
46
-
47
- lib/
48
- └── utils.ts # Utility functions
49
-
50
- public/ # Static assets
51
- ```
52
-
53
38
  ## Recommended Folder & File Structure
54
39
 
55
40
  ```text
@@ -1,5 +1,7 @@
1
+ import { QueryProviders } from "@/components/providers/query-provider";
1
2
  import type { Metadata } from "next";
2
3
  import { Geist, Geist_Mono } from "next/font/google";
4
+ import { Toaster } from "sonner";
3
5
  import "./globals.css";
4
6
 
5
7
  const geistSans = Geist({
@@ -13,8 +15,8 @@ const geistMono = Geist_Mono({
13
15
  });
14
16
 
15
17
  export const metadata: Metadata = {
16
- title: "Create Next App",
17
- description: "Generated by create next app",
18
+ title: "Create Next App - StackKit",
19
+ description: "Generated by create next app with StackKit template",
18
20
  };
19
21
 
20
22
  export default function RootLayout({
@@ -24,7 +26,11 @@ export default function RootLayout({
24
26
  }>) {
25
27
  return (
26
28
  <html lang="en">
27
- <body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>{children}</body>
29
+ <head />
30
+ <body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
31
+ <QueryProviders>{children}</QueryProviders>
32
+ <Toaster theme="system" position="top-right" richColors />
33
+ </body>
28
34
  </html>
29
35
  );
30
36
  }
@@ -0,0 +1,37 @@
1
+ "use client";
2
+
3
+ import { isServer, QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
+ import { ReactQueryStreamedHydration } from "@tanstack/react-query-next-experimental";
5
+
6
+ function makeQueryClient() {
7
+ return new QueryClient({
8
+ defaultOptions: {
9
+ queries: {
10
+ staleTime: 60 * 1000,
11
+ },
12
+ },
13
+ });
14
+ }
15
+
16
+ let browserQueryClient: QueryClient | undefined = undefined;
17
+
18
+ function getQueryClient() {
19
+ if (isServer) {
20
+ return makeQueryClient();
21
+ } else {
22
+ if (!browserQueryClient) browserQueryClient = makeQueryClient();
23
+ return browserQueryClient;
24
+ }
25
+ }
26
+
27
+ function QueryProviders({ children }: { children: React.ReactNode }) {
28
+ const queryClient = getQueryClient();
29
+
30
+ return (
31
+ <QueryClientProvider client={queryClient}>
32
+ <ReactQueryStreamedHydration>{children}</ReactQueryStreamedHydration>
33
+ </QueryClientProvider>
34
+ );
35
+ }
36
+
37
+ export { getQueryClient, QueryProviders };
@@ -0,0 +1,40 @@
1
+ import type { AxiosResponse } from "axios";
2
+ import axios, { AxiosError } from "axios";
3
+ import { toast } from "sonner";
4
+ import { envVars } from "../env";
5
+
6
+ const api = axios.create({
7
+ baseURL: envVars.API_URL || "http://localhost:5000/api",
8
+ timeout: 30000,
9
+ headers: {
10
+ "Content-Type": "application/json",
11
+ },
12
+ });
13
+
14
+ api.interceptors.request.use(
15
+ (config) => config,
16
+ (error: AxiosError) => Promise.reject(error),
17
+ );
18
+
19
+ api.interceptors.response.use(
20
+ (response: AxiosResponse) => response,
21
+ (error: AxiosError) => {
22
+ if (error.response?.status === 401) {
23
+ localStorage.removeItem("auth_token");
24
+ toast.error("Session expired. Please login again.");
25
+ } else if (error.response?.status === 403) {
26
+ toast.error("You do not have permission to perform this action.");
27
+ } else if (error.response?.status === 404) {
28
+ toast.error("Resource not found.");
29
+ } else if (error.response?.status === 500) {
30
+ toast.error("Server error. Please try again later.");
31
+ } else if (error.code === "ECONNABORTED") {
32
+ toast.error("Request timeout. Please try again.");
33
+ } else if (!error.response) {
34
+ toast.error("Network error. Please check your connection.");
35
+ }
36
+ return Promise.reject(error);
37
+ },
38
+ );
39
+
40
+ export { api };
@@ -1,9 +1,10 @@
1
1
  interface EnvVars {
2
2
  APP_URL: string;
3
+ API_URL: string;
3
4
  }
4
5
 
5
6
  const loadEnvVars = (): EnvVars => {
6
- const requiredEnvVars = [""];
7
+ const requiredEnvVars = ["NEXT_PUBLIC_API_URL"];
7
8
 
8
9
  requiredEnvVars.forEach((varName) => {
9
10
  if (!process.env[varName]) {
@@ -13,6 +14,7 @@ const loadEnvVars = (): EnvVars => {
13
14
 
14
15
  return {
15
16
  APP_URL: process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
17
+ API_URL: process.env.NEXT_PUBLIC_API_URL || "http://localhost:5000/api",
16
18
  };
17
19
  };
18
20
 
@@ -10,9 +10,13 @@
10
10
  "lint": "eslint"
11
11
  },
12
12
  "dependencies": {
13
+ "@tanstack/react-query": "^5.90.21",
14
+ "@tanstack/react-query-next-experimental": "^5.91.0",
15
+ "axios": "^1.13.5",
13
16
  "next": "16.1.1",
14
17
  "react": "19.2.3",
15
- "react-dom": "19.2.3"
18
+ "react-dom": "19.2.3",
19
+ "sonner": "^2.0.7"
16
20
  },
17
21
  "devDependencies": {
18
22
  "@tailwindcss/postcss": "^4.1.18",
@@ -24,4 +28,4 @@
24
28
  "tailwindcss": "^4.1.18",
25
29
  "typescript": "^5.9.3"
26
30
  }
27
- }
31
+ }
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "app/",
12
+ "components/",
12
13
  "lib/",
13
14
  "public/",
14
15
  ".env.example",
@@ -48,19 +48,6 @@ VITE_API_URL=http://localhost:3000/api
48
48
  VITE_APP_NAME=My App
49
49
  ```
50
50
 
51
- ## Project Structure
52
-
53
- ```
54
- src/
55
- ├── api/ # API client
56
- ├── components/ # UI components
57
- ├── hooks/ # Custom hooks
58
- ├── lib/ # Utilities
59
- ├── pages/ # Route pages
60
- ├── types/ # TypeScript types
61
- └── utils/ # Helper functions
62
- ```
63
-
64
51
  ## Recommended Folder & File Structure
65
52
 
66
53
  ```text
@@ -3,7 +3,7 @@ import axios, { AxiosError } from "axios";
3
3
  import toast from "react-hot-toast";
4
4
 
5
5
  const api = axios.create({
6
- baseURL: import.meta.env.VITE_API_URL || "http://localhost:3000/api",
6
+ baseURL: import.meta.env.VITE_API_URL || "http://localhost:5000/api",
7
7
  timeout: 10000,
8
8
  headers: {
9
9
  "Content-Type": "application/json",
@@ -11,16 +11,8 @@ const api = axios.create({
11
11
  });
12
12
 
13
13
  api.interceptors.request.use(
14
- (config) => {
15
- const token = localStorage.getItem("auth_token");
16
- if (token) {
17
- (config.headers as Record<string, string>).Authorization = `Bearer ${token}`;
18
- }
19
- return config;
20
- },
21
- (error: AxiosError) => {
22
- return Promise.reject(error);
23
- },
14
+ (config) => config,
15
+ (error: AxiosError) => Promise.reject(error),
24
16
  );
25
17
 
26
18
  api.interceptors.response.use(