create-stackkit-app 0.4.0 → 0.4.2
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 +25 -11
- package/dist/lib/create-project.js +88 -8
- package/dist/lib/template-composer.js +1 -1
- package/modules/auth/better-auth-express/adapters/mongoose-mongodb.ts +13 -0
- package/modules/auth/better-auth-express/adapters/prisma-mongodb.ts +15 -0
- package/modules/auth/better-auth-express/adapters/prisma-postgresql.ts +15 -0
- package/modules/auth/better-auth-express/files/schemas/prisma-mongodb-schema.prisma +72 -0
- package/modules/auth/better-auth-express/files/schemas/prisma-postgresql-schema.prisma +72 -0
- package/modules/auth/better-auth-express/module.json +26 -3
- package/modules/auth/better-auth-nextjs/adapters/mongoose-mongodb.ts +24 -0
- package/modules/auth/better-auth-nextjs/adapters/prisma-mongodb.ts +26 -0
- package/modules/auth/better-auth-nextjs/adapters/prisma-postgresql.ts +26 -0
- package/modules/auth/better-auth-nextjs/files/schemas/prisma-mongodb-schema.prisma +72 -0
- package/modules/auth/better-auth-nextjs/files/schemas/prisma-postgresql-schema.prisma +72 -0
- package/modules/auth/better-auth-nextjs/module.json +26 -5
- package/modules/auth/better-auth-react/module.json +7 -5
- package/modules/auth/clerk-express/module.json +23 -8
- package/modules/auth/clerk-nextjs/module.json +51 -14
- package/modules/auth/clerk-react/module.json +17 -7
- package/modules/database/mongoose-mongodb/module.json +44 -6
- package/modules/database/prisma-mongodb/files/prisma/schema.prisma +1 -1
- package/modules/database/prisma-mongodb/module.json +28 -4
- package/modules/database/prisma-postgresql/files/prisma/schema.prisma +1 -1
- package/modules/database/prisma-postgresql/module.json +28 -4
- package/package.json +3 -3
- package/templates/express/.env.example +11 -0
- package/templates/express/eslint.config.cjs +42 -0
- package/templates/express/package.json +38 -0
- package/templates/express/src/app.ts +69 -0
- package/templates/express/src/config/env.ts +23 -0
- package/templates/express/src/middlewares/error.middleware.ts +18 -0
- package/templates/express/src/server.ts +8 -0
- package/templates/{bases/express-base → express}/template.json +1 -1
- package/templates/express/tsconfig.json +14 -0
- package/templates/{bases/nextjs-base → nextjs}/app/page.tsx +5 -5
- package/templates/{bases/nextjs-base → nextjs}/template.json +1 -1
- package/templates/react-vite/.env.example +2 -0
- package/templates/react-vite/README.md +85 -0
- package/templates/react-vite/eslint.config.js +23 -0
- package/templates/{bases/react-vite-base → react-vite}/index.html +2 -1
- package/templates/react-vite/package.json +45 -0
- package/templates/react-vite/public/vite.svg +1 -0
- package/templates/react-vite/src/api/client.ts +47 -0
- package/templates/react-vite/src/api/services/user.service.ts +26 -0
- package/templates/react-vite/src/assets/react.svg +1 -0
- package/templates/react-vite/src/components/ErrorBoundary.tsx +51 -0
- package/templates/react-vite/src/components/Layout.tsx +13 -0
- package/templates/react-vite/src/components/Loading.tsx +8 -0
- package/templates/react-vite/src/components/SEO.tsx +49 -0
- package/templates/react-vite/src/config/constants.ts +5 -0
- package/templates/react-vite/src/hooks/index.ts +64 -0
- package/templates/react-vite/src/index.css +1 -0
- package/templates/react-vite/src/lib/queryClient.ts +12 -0
- package/templates/react-vite/src/main.tsx +22 -0
- package/templates/react-vite/src/pages/About.tsx +74 -0
- package/templates/react-vite/src/pages/Home.tsx +45 -0
- package/templates/react-vite/src/pages/NotFound.tsx +24 -0
- package/templates/react-vite/src/pages/UserProfile.tsx +40 -0
- package/templates/react-vite/src/router.tsx +33 -0
- package/templates/react-vite/src/types/api.ts +20 -0
- package/templates/react-vite/src/utils/helpers.ts +51 -0
- package/templates/react-vite/src/utils/storage.ts +35 -0
- package/templates/react-vite/src/vite-env.d.ts +11 -0
- package/templates/react-vite/template.json +20 -0
- package/templates/{bases/react-vite-base/tsconfig.json → react-vite/tsconfig.app.json} +10 -3
- package/templates/react-vite/tsconfig.json +7 -0
- package/templates/react-vite/tsconfig.node.json +26 -0
- package/templates/react-vite/vite.config.ts +13 -0
- package/modules/auth/authjs-express/files/lib/auth.ts +0 -40
- package/modules/auth/authjs-express/files/routes/auth.ts +0 -12
- package/modules/auth/authjs-express/module.json +0 -39
- package/modules/auth/authjs-nextjs/files/api/auth/[...nextauth]/route.ts +0 -3
- package/modules/auth/authjs-nextjs/files/lib/auth.ts +0 -43
- package/modules/auth/authjs-nextjs/module.json +0 -38
- package/modules/auth/nextauth/files/app-router/api/auth/[...nextauth]/route.ts +0 -6
- package/modules/auth/nextauth/files/lib/auth.ts +0 -82
- package/modules/auth/nextauth/files/pages-router/api/auth/[...nextauth].ts +0 -4
- package/modules/auth/nextauth/module.json +0 -50
- package/modules/database/drizzle-postgresql/files/drizzle.config.ts +0 -10
- package/modules/database/drizzle-postgresql/files/lib/db.ts +0 -7
- package/modules/database/drizzle-postgresql/files/lib/schema.ts +0 -8
- package/modules/database/drizzle-postgresql/module.json +0 -34
- package/templates/bases/express-base/.env.example +0 -2
- package/templates/bases/express-base/package.json +0 -23
- package/templates/bases/express-base/src/index.ts +0 -27
- package/templates/bases/express-base/tsconfig.json +0 -17
- package/templates/bases/nextjs-base/package-lock.json +0 -6538
- package/templates/bases/react-vite-base/package.json +0 -27
- package/templates/bases/react-vite-base/src/App.css +0 -14
- package/templates/bases/react-vite-base/src/App.tsx +0 -23
- package/templates/bases/react-vite-base/src/index.css +0 -68
- package/templates/bases/react-vite-base/src/main.tsx +0 -10
- package/templates/bases/react-vite-base/src/vite-env.d.ts +0 -1
- package/templates/bases/react-vite-base/template.json +0 -5
- package/templates/bases/react-vite-base/vite.config.ts +0 -7
- /package/templates/{bases/nextjs-base → nextjs}/README.md +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/app/favicon.ico +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/app/globals.css +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/app/layout.tsx +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/eslint.config.mjs +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/next.config.ts +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/package.json +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/postcss.config.mjs +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/file.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/globe.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/next.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/vercel.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/public/window.svg +0 -0
- /package/templates/{bases/nextjs-base → nextjs}/tsconfig.json +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "./src",
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"target": "ES2023",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"ignoreDeprecations": "5.0"
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"],
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|
|
@@ -17,20 +17,20 @@ export default function Home() {
|
|
|
17
17
|
To get started, edit the page.tsx file.
|
|
18
18
|
</h1>
|
|
19
19
|
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
|
20
|
-
Looking for a starting point or more instructions? Head over to{
|
|
20
|
+
Looking for a starting point or more instructions? Head over to{' '}
|
|
21
21
|
<a
|
|
22
22
|
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
|
23
23
|
className="font-medium text-zinc-950 dark:text-zinc-50"
|
|
24
24
|
>
|
|
25
25
|
Templates
|
|
26
|
-
</a>{
|
|
27
|
-
or the{
|
|
26
|
+
</a>{' '}
|
|
27
|
+
or the{' '}
|
|
28
28
|
<a
|
|
29
29
|
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
|
30
30
|
className="font-medium text-zinc-950 dark:text-zinc-50"
|
|
31
31
|
>
|
|
32
32
|
Learning
|
|
33
|
-
</a>{
|
|
33
|
+
</a>{' '}
|
|
34
34
|
center.
|
|
35
35
|
</p>
|
|
36
36
|
</div>
|
|
@@ -51,7 +51,7 @@ export default function Home() {
|
|
|
51
51
|
Deploy Now
|
|
52
52
|
</a>
|
|
53
53
|
<a
|
|
54
|
-
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/
|
|
54
|
+
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/8 px-5 transition-colors hover:border-transparent hover:bg-black/4 dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
|
|
55
55
|
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
|
56
56
|
target="_blank"
|
|
57
57
|
rel="noopener noreferrer"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# React + Vite Template
|
|
2
|
+
|
|
3
|
+
A production-ready React starter template with TypeScript, Vite, and essential libraries pre-configured.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **React 19** with TypeScript
|
|
8
|
+
- **Vite 7** for fast development
|
|
9
|
+
- **React Router v7** for client-side routing
|
|
10
|
+
- **TanStack Query v5** for data fetching and caching
|
|
11
|
+
- **Axios** with interceptors
|
|
12
|
+
- **Tailwind CSS** for styling
|
|
13
|
+
- **React Hot Toast** for notifications
|
|
14
|
+
- **SEO Ready** with React Helmet Async
|
|
15
|
+
- **Error Boundaries** for graceful error handling
|
|
16
|
+
- **ESLint** for code quality
|
|
17
|
+
- **Custom Hooks** included
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install dependencies
|
|
23
|
+
pnpm install
|
|
24
|
+
|
|
25
|
+
# Start development server
|
|
26
|
+
pnpm dev
|
|
27
|
+
|
|
28
|
+
# Build for production
|
|
29
|
+
pnpm build
|
|
30
|
+
|
|
31
|
+
# Preview production build
|
|
32
|
+
pnpm preview
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Project Structure
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
src/
|
|
39
|
+
├── api/ # API client & interceptors
|
|
40
|
+
├── components/ # Reusable UI components
|
|
41
|
+
├── config/ # App configuration
|
|
42
|
+
├── hooks/ # Custom React hooks
|
|
43
|
+
├── lib/ # Library configurations
|
|
44
|
+
├── pages/ # Route pages
|
|
45
|
+
├── types/ # TypeScript types
|
|
46
|
+
├── utils/ # Helper functions
|
|
47
|
+
├── App.tsx # Main app component
|
|
48
|
+
├── main.tsx # Entry point
|
|
49
|
+
└── index.css # Global styles
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Environment Variables
|
|
53
|
+
|
|
54
|
+
Create a `.env` file:
|
|
55
|
+
|
|
56
|
+
```env
|
|
57
|
+
VITE_API_URL=http://localhost:3000/api
|
|
58
|
+
VITE_APP_NAME=My App
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Production Build
|
|
62
|
+
|
|
63
|
+
- Code splitting with vendor chunks
|
|
64
|
+
- Tree shaking to remove unused code
|
|
65
|
+
- Minified and compressed output
|
|
66
|
+
- TypeScript strict mode enabled
|
|
67
|
+
- ESLint configured for code quality
|
|
68
|
+
|
|
69
|
+
## Deployment
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm build
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Deploy the `dist` folder to Vercel, Netlify, or any static hosting service.
|
|
76
|
+
|
|
77
|
+
## Tech Stack
|
|
78
|
+
|
|
79
|
+
- React 19 - UI library
|
|
80
|
+
- Vite 7 - Build tool
|
|
81
|
+
- TypeScript - Type safety
|
|
82
|
+
- React Router v7 - Routing
|
|
83
|
+
- TanStack Query v5 - Data fetching
|
|
84
|
+
- Axios - HTTP client
|
|
85
|
+
- Tailwind CSS - Styling
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from 'typescript-eslint'
|
|
6
|
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
globalIgnores(['dist']),
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
|
12
|
+
extends: [
|
|
13
|
+
js.configs.recommended,
|
|
14
|
+
tseslint.configs.recommended,
|
|
15
|
+
reactHooks.configs.flat.recommended,
|
|
16
|
+
reactRefresh.configs.vite,
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
globals: globals.browser,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
])
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<
|
|
7
|
+
<link href="/src/index.css" rel="stylesheet">
|
|
8
|
+
<title>react-vite-base</title>
|
|
8
9
|
</head>
|
|
9
10
|
<body>
|
|
10
11
|
<div id="root"></div>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-vite-base",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc -b && vite build",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"lint:fix": "eslint . --fix",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"type-check": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
16
|
+
"@tanstack/react-query": "^5.62.0",
|
|
17
|
+
"@tanstack/react-query-devtools": "^5.62.0",
|
|
18
|
+
"axios": "^1.7.7",
|
|
19
|
+
"class-variance-authority": "^0.7.1",
|
|
20
|
+
"clsx": "^2.1.1",
|
|
21
|
+
"react": "^19.2.0",
|
|
22
|
+
"react-dom": "^19.2.0",
|
|
23
|
+
"react-helmet-async": "^2.0.5",
|
|
24
|
+
"react-hot-toast": "^2.4.1",
|
|
25
|
+
"react-router": "^7.12.0",
|
|
26
|
+
"tailwind-merge": "^3.4.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@eslint/js": "^9.39.1",
|
|
30
|
+
"@types/node": "^24.10.1",
|
|
31
|
+
"@types/react": "^19.2.5",
|
|
32
|
+
"@types/react-dom": "^19.2.3",
|
|
33
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
34
|
+
"autoprefixer": "^10.4.23",
|
|
35
|
+
"eslint": "^9.39.1",
|
|
36
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
37
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
38
|
+
"globals": "^16.5.0",
|
|
39
|
+
"postcss": "^8.5.6",
|
|
40
|
+
"tailwindcss": "^4.1.18",
|
|
41
|
+
"typescript": "~5.9.3",
|
|
42
|
+
"typescript-eslint": "^8.46.4",
|
|
43
|
+
"vite": "^7.2.4"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AxiosResponse } from 'axios';
|
|
2
|
+
import axios, { AxiosError } from 'axios';
|
|
3
|
+
import toast from 'react-hot-toast';
|
|
4
|
+
|
|
5
|
+
const api = axios.create({
|
|
6
|
+
baseURL: import.meta.env.VITE_API_URL || 'http://localhost:3000/api',
|
|
7
|
+
timeout: 10000,
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
api.interceptors.request.use(
|
|
14
|
+
(config) => {
|
|
15
|
+
const token = localStorage.getItem('auth_token');
|
|
16
|
+
if (token) {
|
|
17
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
18
|
+
}
|
|
19
|
+
return config;
|
|
20
|
+
},
|
|
21
|
+
(error: AxiosError) => {
|
|
22
|
+
return Promise.reject(error);
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
api.interceptors.response.use(
|
|
27
|
+
(response: AxiosResponse) => response,
|
|
28
|
+
(error: AxiosError) => {
|
|
29
|
+
if (error.response?.status === 401) {
|
|
30
|
+
localStorage.removeItem('auth_token');
|
|
31
|
+
toast.error('Session expired. Please login again.');
|
|
32
|
+
} else if (error.response?.status === 403) {
|
|
33
|
+
toast.error('You do not have permission to perform this action.');
|
|
34
|
+
} else if (error.response?.status === 404) {
|
|
35
|
+
toast.error('Resource not found.');
|
|
36
|
+
} else if (error.response?.status === 500) {
|
|
37
|
+
toast.error('Server error. Please try again later.');
|
|
38
|
+
} else if (error.code === 'ECONNABORTED') {
|
|
39
|
+
toast.error('Request timeout. Please try again.');
|
|
40
|
+
} else if (!error.response) {
|
|
41
|
+
toast.error('Network error. Please check your connection.');
|
|
42
|
+
}
|
|
43
|
+
return Promise.reject(error);
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default api;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ApiResponse } from '../../types/api';
|
|
2
|
+
import api from '../client';
|
|
3
|
+
|
|
4
|
+
export interface User {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
email: string;
|
|
8
|
+
avatar?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const userService = {
|
|
12
|
+
getUser: async (id: string): Promise<User> => {
|
|
13
|
+
const response = await api.get<ApiResponse<User>>(`/users/${id}`);
|
|
14
|
+
return response.data.data;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
getCurrentUser: async (): Promise<User> => {
|
|
18
|
+
const response = await api.get<ApiResponse<User>>('/users/me');
|
|
19
|
+
return response.data.data;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
updateUser: async (id: string, data: Partial<User>): Promise<User> => {
|
|
23
|
+
const response = await api.patch<ApiResponse<User>>(`/users/${id}`, data);
|
|
24
|
+
return response.data.data;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
fallback?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface State {
|
|
10
|
+
hasError: boolean;
|
|
11
|
+
error?: Error;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ErrorBoundary extends Component<Props, State> {
|
|
15
|
+
constructor(props: Props) {
|
|
16
|
+
super(props);
|
|
17
|
+
this.state = { hasError: false };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static getDerivedStateFromError(error: Error): State {
|
|
21
|
+
return { hasError: true, error };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
25
|
+
console.error('ErrorBoundary caught an error:', error, errorInfo);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
render() {
|
|
29
|
+
if (this.state.hasError) {
|
|
30
|
+
if (this.props.fallback) {
|
|
31
|
+
return this.props.fallback;
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
<div className="p-8 text-center">
|
|
35
|
+
<h2 className="text-2xl font-semibold">Something went wrong</h2>
|
|
36
|
+
<p className="mt-2 text-gray-600">
|
|
37
|
+
{this.state.error?.message || 'An unexpected error occurred'}
|
|
38
|
+
</p>
|
|
39
|
+
<button
|
|
40
|
+
onClick={() => this.setState({ hasError: false, error: undefined })}
|
|
41
|
+
className="mt-4 flex h-12 w-full items-center justify-center rounded-full bg-white text-black px-5 transition-colors hover:bg-zinc-200 md:w-39.5"
|
|
42
|
+
>
|
|
43
|
+
Try again
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this.props.children;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Outlet } from 'react-router';
|
|
2
|
+
|
|
3
|
+
export function Layout() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="min-h-screen flex flex-col bg-black">
|
|
6
|
+
<main className="flex-1 max-w-7xl w-full mx-auto p-4">
|
|
7
|
+
<Outlet />
|
|
8
|
+
</main>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default Layout;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Helmet, HelmetProvider } from 'react-helmet-async';
|
|
2
|
+
|
|
3
|
+
interface SEOProps {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
keywords?: string;
|
|
7
|
+
image?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const defaultSEO = {
|
|
12
|
+
title: 'React App',
|
|
13
|
+
description: 'A modern React application built with Vite',
|
|
14
|
+
keywords: 'react, vite, typescript, spa',
|
|
15
|
+
image: '/og-image.png',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function SEOProvider({ children }: { children: React.ReactNode }) {
|
|
19
|
+
return <HelmetProvider>{children}</HelmetProvider>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function SEO({ title, description, keywords, image, url }: SEOProps) {
|
|
23
|
+
const siteTitle = title ? `${title} | ${defaultSEO.title}` : defaultSEO.title;
|
|
24
|
+
const siteDescription = description || defaultSEO.description;
|
|
25
|
+
const siteKeywords = keywords || defaultSEO.keywords;
|
|
26
|
+
const siteImage = image || defaultSEO.image;
|
|
27
|
+
const siteUrl = url || window.location.href;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Helmet>
|
|
31
|
+
<title>{siteTitle}</title>
|
|
32
|
+
<meta name="description" content={siteDescription} />
|
|
33
|
+
<meta name="keywords" content={siteKeywords} />
|
|
34
|
+
|
|
35
|
+
<meta property="og:type" content="website" />
|
|
36
|
+
<meta property="og:title" content={siteTitle} />
|
|
37
|
+
<meta property="og:description" content={siteDescription} />
|
|
38
|
+
<meta property="og:image" content={siteImage} />
|
|
39
|
+
<meta property="og:url" content={siteUrl} />
|
|
40
|
+
|
|
41
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
42
|
+
<meta name="twitter:title" content={siteTitle} />
|
|
43
|
+
<meta name="twitter:description" content={siteDescription} />
|
|
44
|
+
<meta name="twitter:image" content={siteImage} />
|
|
45
|
+
|
|
46
|
+
<link rel="canonical" href={siteUrl} />
|
|
47
|
+
</Helmet>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const APP_NAME = import.meta.env.VITE_APP_NAME || 'React App';
|
|
2
|
+
export const APP_VERSION = import.meta.env.VITE_APP_VERSION || '1.0.0';
|
|
3
|
+
export const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000/api';
|
|
4
|
+
export const IS_DEV = import.meta.env.DEV;
|
|
5
|
+
export const IS_PROD = import.meta.env.PROD;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export function useDebounce<T>(value: T, delay: number): T {
|
|
4
|
+
const [debouncedValue, setDebouncedValue] = useState<T>(value);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handler = setTimeout(() => {
|
|
8
|
+
setDebouncedValue(value);
|
|
9
|
+
}, delay);
|
|
10
|
+
|
|
11
|
+
return () => {
|
|
12
|
+
clearTimeout(handler);
|
|
13
|
+
};
|
|
14
|
+
}, [value, delay]);
|
|
15
|
+
|
|
16
|
+
return debouncedValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useLocalStorage<T>(
|
|
20
|
+
key: string,
|
|
21
|
+
initialValue: T
|
|
22
|
+
): [T, (value: T | ((val: T) => T)) => void] {
|
|
23
|
+
const [storedValue, setStoredValue] = useState<T>(() => {
|
|
24
|
+
try {
|
|
25
|
+
const item = window.localStorage.getItem(key);
|
|
26
|
+
return item ? JSON.parse(item) : initialValue;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
return initialValue;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const setValue = (value: T | ((val: T) => T)) => {
|
|
34
|
+
try {
|
|
35
|
+
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
36
|
+
setStoredValue(valueToStore);
|
|
37
|
+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(error);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return [storedValue, setValue];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function useMediaQuery(query: string): boolean {
|
|
47
|
+
const [matches, setMatches] = useState(() => {
|
|
48
|
+
if (typeof window !== 'undefined') {
|
|
49
|
+
return window.matchMedia(query).matches;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const media = window.matchMedia(query);
|
|
56
|
+
|
|
57
|
+
const listener = () => setMatches(media.matches);
|
|
58
|
+
media.addEventListener('change', listener);
|
|
59
|
+
|
|
60
|
+
return () => media.removeEventListener('change', listener);
|
|
61
|
+
}, [query]);
|
|
62
|
+
|
|
63
|
+
return matches;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
export const queryClient = new QueryClient({
|
|
4
|
+
defaultOptions: {
|
|
5
|
+
queries: {
|
|
6
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
7
|
+
gcTime: 1000 * 60 * 10, // 10 minutes (formerly cacheTime)
|
|
8
|
+
retry: 1,
|
|
9
|
+
refetchOnWindowFocus: false,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
2
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
3
|
+
import { StrictMode } from 'react';
|
|
4
|
+
import { createRoot } from 'react-dom/client';
|
|
5
|
+
import { Toaster } from 'react-hot-toast';
|
|
6
|
+
import { RouterProvider } from 'react-router';
|
|
7
|
+
import { SEOProvider } from './components/SEO';
|
|
8
|
+
import './index.css';
|
|
9
|
+
import { queryClient } from './lib/queryClient';
|
|
10
|
+
import { router } from './router';
|
|
11
|
+
|
|
12
|
+
createRoot(document.getElementById('root')!).render(
|
|
13
|
+
<StrictMode>
|
|
14
|
+
<SEOProvider>
|
|
15
|
+
<QueryClientProvider client={queryClient}>
|
|
16
|
+
<RouterProvider router={router} />
|
|
17
|
+
<Toaster position="top-right" />
|
|
18
|
+
<ReactQueryDevtools initialIsOpen={false} />
|
|
19
|
+
</QueryClientProvider>
|
|
20
|
+
</SEOProvider>
|
|
21
|
+
</StrictMode>
|
|
22
|
+
);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { SEO } from '../components/SEO';
|
|
2
|
+
|
|
3
|
+
export default function About() {
|
|
4
|
+
return (
|
|
5
|
+
<>
|
|
6
|
+
<SEO title="About" description="About Stackkit - A production-ready React starter template" />
|
|
7
|
+
|
|
8
|
+
<div className="flex min-h-screen items-center justify-center bg-black">
|
|
9
|
+
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-black sm:items-start">
|
|
10
|
+
<div className="text-2xl font-bold text-white">Stackkit</div>
|
|
11
|
+
|
|
12
|
+
<div className="flex flex-col gap-12 sm:text-left">
|
|
13
|
+
<div>
|
|
14
|
+
<h1 className="text-3xl font-semibold leading-10 tracking-tight text-zinc-50 mb-6">
|
|
15
|
+
About this template
|
|
16
|
+
</h1>
|
|
17
|
+
<p className="text-lg leading-8 text-zinc-400 mb-8">
|
|
18
|
+
Stackkit is a production-ready React starter template that includes all the
|
|
19
|
+
essential tools you need to build modern web applications.
|
|
20
|
+
</p>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div>
|
|
24
|
+
<h2 className="text-xl font-semibold text-zinc-50 mb-4">What's included</h2>
|
|
25
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4 text-zinc-400">
|
|
26
|
+
<div className="p-4 border border-zinc-800 rounded-lg">
|
|
27
|
+
<div className="font-medium text-zinc-50 mb-1">React 19</div>
|
|
28
|
+
<div className="text-sm">Latest React with TypeScript</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div className="p-4 border border-zinc-800 rounded-lg">
|
|
31
|
+
<div className="font-medium text-zinc-50 mb-1">Vite 7</div>
|
|
32
|
+
<div className="text-sm">Fast build tool and dev server</div>
|
|
33
|
+
</div>
|
|
34
|
+
<div className="p-4 border border-zinc-800 rounded-lg">
|
|
35
|
+
<div className="font-medium text-zinc-50 mb-1">React Router</div>
|
|
36
|
+
<div className="text-sm">Client-side routing</div>
|
|
37
|
+
</div>
|
|
38
|
+
<div className="p-4 border border-zinc-800 rounded-lg">
|
|
39
|
+
<div className="font-medium text-zinc-50 mb-1">TanStack Query</div>
|
|
40
|
+
<div className="text-sm">Data fetching and caching</div>
|
|
41
|
+
</div>
|
|
42
|
+
<div className="p-4 border border-zinc-800 rounded-lg">
|
|
43
|
+
<div className="font-medium text-zinc-50 mb-1">Axios</div>
|
|
44
|
+
<div className="text-sm">HTTP client with interceptors</div>
|
|
45
|
+
</div>
|
|
46
|
+
<div className="p-4 border border-zinc-800 rounded-lg">
|
|
47
|
+
<div className="font-medium text-zinc-50 mb-1">Tailwind CSS</div>
|
|
48
|
+
<div className="text-sm">Utility-first CSS framework</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row mt-8">
|
|
55
|
+
<a
|
|
56
|
+
className="flex h-12 w-full items-center justify-center rounded-full bg-white text-black px-5 transition-colors hover:bg-zinc-200 md:w-39.5"
|
|
57
|
+
href="/"
|
|
58
|
+
>
|
|
59
|
+
Back to Home
|
|
60
|
+
</a>
|
|
61
|
+
<a
|
|
62
|
+
className="flex h-12 w-full items-center justify-center rounded-full px-5 transition-colors hover:border-transparent bg-zinc-900 md:w-39.5 dark:text-white text-black"
|
|
63
|
+
href="https://stackkit.tariqul.dev"
|
|
64
|
+
target="_blank"
|
|
65
|
+
rel="noopener noreferrer"
|
|
66
|
+
>
|
|
67
|
+
Website
|
|
68
|
+
</a>
|
|
69
|
+
</div>
|
|
70
|
+
</main>
|
|
71
|
+
</div>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|