create-reactivite 1.4.0 → 1.6.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 +326 -290
- package/index.js +1 -1
- package/package.json +4 -2
- package/template/package.json +22 -22
- package/template/pnpm-lock.yaml +3274 -3274
- package/template/src/components/author-credit.tsx +25 -25
- package/template2/.env.example +8 -8
- package/template2/.husky/pre-commit +4 -4
- package/template2/.prettierrc +5 -5
- package/template2/README.md +73 -73
- package/template2/__tests__/example.test.ts +20 -20
- package/template2/_gitignore +37 -37
- package/template2/app/[locale]/(private)/dashboard/page.tsx +52 -52
- package/template2/app/[locale]/(public)/login/page.tsx +83 -83
- package/template2/app/[locale]/layout.tsx +58 -58
- package/template2/app/[locale]/locales.ts +10 -10
- package/template2/app/[locale]/page.tsx +38 -38
- package/template2/app/api/clear-session/route.ts +10 -10
- package/template2/app/globals.css +127 -127
- package/template2/app/layout.tsx +7 -7
- package/template2/app/page.tsx +6 -6
- package/template2/components/AuthEventListener.tsx +22 -22
- package/template2/components/author-credit.tsx +25 -25
- package/template2/components/theme-provider.tsx +78 -78
- package/template2/components/ui/button.tsx +60 -60
- package/template2/components/ui/card.tsx +92 -92
- package/template2/components/ui/input.tsx +21 -21
- package/template2/components/ui/label.tsx +24 -24
- package/template2/components/ui/sonner.tsx +40 -40
- package/template2/components.json +22 -22
- package/template2/config/constants.ts +7 -7
- package/template2/config/env.ts +5 -5
- package/template2/contexts/translation-context.tsx +70 -70
- package/template2/eslint.config.mjs +18 -18
- package/template2/hoc/provider.tsx +27 -27
- package/template2/lib/paramsSerializer.ts +40 -40
- package/template2/lib/utils.ts +6 -6
- package/template2/locales/az.json +20 -20
- package/template2/locales/en.json +20 -20
- package/template2/next-env.d.ts +1 -1
- package/template2/next.config.ts +17 -17
- package/template2/orval.config.ts +66 -66
- package/template2/package.json +62 -62
- package/template2/postcss.config.mjs +7 -7
- package/template2/scripts/fix-generated-types.mjs +13 -13
- package/template2/services/generated/.gitkeep +2 -2
- package/template2/services/httpClient/httpClient.ts +70 -70
- package/template2/services/httpClient/orvalMutator.ts +10 -10
- package/template2/store/example-store.tsx +16 -16
- package/template2/store/user-store.tsx +29 -29
- package/template2/testing/msw/handlers/index.ts +6 -6
- package/template2/testing/msw/server.ts +4 -4
- package/template2/tsconfig.json +34 -34
- package/template2/vitest.config.ts +17 -17
- package/template2/vitest.setup.ts +7 -7
- package/template3/README.md +34 -34
- package/template3/_gitignore +16 -16
- package/template3/components.json +21 -0
- package/template3/index.html +8 -2
- package/template3/package-lock.json +3934 -0
- package/template3/package.json +48 -22
- package/template3/postcss.config.mjs +5 -0
- package/template3/rspack.config.mjs +59 -51
- package/template3/src/App.tsx +16 -11
- package/template3/src/components/author-credit.tsx +42 -42
- package/template3/src/components/layout.tsx +59 -0
- package/template3/src/components/matrix-rain.tsx +71 -0
- package/template3/src/components/ui/accordion.tsx +64 -0
- package/template3/src/components/ui/alert-dialog.tsx +196 -0
- package/template3/src/components/ui/alert.tsx +66 -0
- package/template3/src/components/ui/aspect-ratio.tsx +11 -0
- package/template3/src/components/ui/avatar.tsx +107 -0
- package/template3/src/components/ui/badge.tsx +48 -0
- package/template3/src/components/ui/breadcrumb.tsx +109 -0
- package/template3/src/components/ui/button-group.tsx +83 -0
- package/template3/src/components/ui/button.tsx +64 -0
- package/template3/src/components/ui/calendar.tsx +218 -0
- package/template3/src/components/ui/card.tsx +92 -0
- package/template3/src/components/ui/carousel.tsx +241 -0
- package/template3/src/components/ui/chart.tsx +372 -0
- package/template3/src/components/ui/checkbox.tsx +32 -0
- package/template3/src/components/ui/collapsible.tsx +31 -0
- package/template3/src/components/ui/combobox.tsx +310 -0
- package/template3/src/components/ui/command.tsx +184 -0
- package/template3/src/components/ui/context-menu.tsx +252 -0
- package/template3/src/components/ui/dialog.tsx +156 -0
- package/template3/src/components/ui/direction.tsx +22 -0
- package/template3/src/components/ui/drawer.tsx +133 -0
- package/template3/src/components/ui/dropdown-menu.tsx +257 -0
- package/template3/src/components/ui/empty.tsx +104 -0
- package/template3/src/components/ui/field.tsx +248 -0
- package/template3/src/components/ui/form.tsx +165 -0
- package/template3/src/components/ui/hover-card.tsx +42 -0
- package/template3/src/components/ui/input-group.tsx +168 -0
- package/template3/src/components/ui/input-otp.tsx +77 -0
- package/template3/src/components/ui/input.tsx +21 -0
- package/template3/src/components/ui/item.tsx +193 -0
- package/template3/src/components/ui/kbd.tsx +28 -0
- package/template3/src/components/ui/label.tsx +22 -0
- package/template3/src/components/ui/menubar.tsx +276 -0
- package/template3/src/components/ui/native-select.tsx +62 -0
- package/template3/src/components/ui/navigation-menu.tsx +168 -0
- package/template3/src/components/ui/pagination.tsx +127 -0
- package/template3/src/components/ui/popover.tsx +87 -0
- package/template3/src/components/ui/progress.tsx +31 -0
- package/template3/src/components/ui/radio-group.tsx +43 -0
- package/template3/src/components/ui/resizable.tsx +53 -0
- package/template3/src/components/ui/scroll-area.tsx +56 -0
- package/template3/src/components/ui/select.tsx +190 -0
- package/template3/src/components/ui/separator.tsx +26 -0
- package/template3/src/components/ui/sheet.tsx +143 -0
- package/template3/src/components/ui/sidebar.tsx +724 -0
- package/template3/src/components/ui/skeleton.tsx +13 -0
- package/template3/src/components/ui/slider.tsx +61 -0
- package/template3/src/components/ui/sonner.tsx +40 -0
- package/template3/src/components/ui/spinner.tsx +16 -0
- package/template3/src/components/ui/switch.tsx +33 -0
- package/template3/src/components/ui/table.tsx +116 -0
- package/template3/src/components/ui/tabs.tsx +89 -0
- package/template3/src/components/ui/textarea.tsx +18 -0
- package/template3/src/components/ui/toggle-group.tsx +83 -0
- package/template3/src/components/ui/toggle.tsx +47 -0
- package/template3/src/components/ui/tooltip.tsx +55 -0
- package/template3/src/hooks/use-mobile.ts +19 -0
- package/template3/src/index.css +175 -32
- package/template3/src/lib/utils.ts +6 -0
- package/template3/src/main.tsx +10 -10
- package/template3/src/pages/about.tsx +113 -0
- package/template3/src/pages/contact.tsx +111 -0
- package/template3/src/pages/home.tsx +81 -0
- package/template3/tsconfig.json +24 -20
- package/template2/tsconfig.tsbuildinfo +0 -1
package/template2/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "nextivite-plate",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "next dev",
|
|
7
|
-
"dev:4000": "next dev -p 4000",
|
|
8
|
-
"build": "next build",
|
|
9
|
-
"start": "next start",
|
|
10
|
-
"lint": "eslint",
|
|
11
|
-
"prepare": "husky",
|
|
12
|
-
"format": "prettier --write \"app/**/*.{js,ts,tsx}\"",
|
|
13
|
-
"format:services": "prettier --write \"services/**/*.{js,ts,tsx}\"",
|
|
14
|
-
"generate": "orval --config orval.config.ts",
|
|
15
|
-
"generate:api": "npm run generate && npm run format:services && node scripts/fix-generated-types.mjs",
|
|
16
|
-
"dev:full": "npm run generate:api && npm run dev",
|
|
17
|
-
"test": "vitest",
|
|
18
|
-
"test:run": "vitest run"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@hookform/resolvers": "^5.
|
|
22
|
-
"@radix-ui/react-label": "^2.1.
|
|
23
|
-
"@radix-ui/react-slot": "^1.
|
|
24
|
-
"@tanstack/react-query": "^5.
|
|
25
|
-
"@tanstack/react-query-devtools": "^5.
|
|
26
|
-
"axios": "^1.
|
|
27
|
-
"class-variance-authority": "^0.7.1",
|
|
28
|
-
"clsx": "^2.1.1",
|
|
29
|
-
"lucide-react": "^
|
|
30
|
-
"next": "^16.2.
|
|
31
|
-
"next-themes": "^0.4.6",
|
|
32
|
-
"react": "19.2.
|
|
33
|
-
"react-dom": "19.2.
|
|
34
|
-
"react-hook-form": "^7.
|
|
35
|
-
"sonner": "^2.0.7",
|
|
36
|
-
"tailwind-merge": "^3.
|
|
37
|
-
"zod": "^4.
|
|
38
|
-
"zustand": "^5.0.
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@tailwindcss/postcss": "^4",
|
|
42
|
-
"@testing-library/jest-dom": "^6.9.1",
|
|
43
|
-
"@testing-library/react": "^16.3.2",
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"@types/react": "^19",
|
|
46
|
-
"@types/react-dom": "^19",
|
|
47
|
-
"@vitejs/plugin-react": "^6.0.
|
|
48
|
-
"eslint": "^
|
|
49
|
-
"eslint-config-next": "^16.2.
|
|
50
|
-
"eslint-config-prettier": "^10.1.8",
|
|
51
|
-
"figlet": "^1.
|
|
52
|
-
"husky": "^9.1.7",
|
|
53
|
-
"jsdom": "^29.1.1",
|
|
54
|
-
"msw": "^2.14.6",
|
|
55
|
-
"orval": "^8.
|
|
56
|
-
"prettier": "^3.
|
|
57
|
-
"tailwindcss": "^4",
|
|
58
|
-
"tw-animate-css": "^1.4.0",
|
|
59
|
-
"typescript": "
|
|
60
|
-
"vitest": "^4.1.
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "nextivite-plate",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"dev:4000": "next dev -p 4000",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "next start",
|
|
10
|
+
"lint": "eslint",
|
|
11
|
+
"prepare": "husky",
|
|
12
|
+
"format": "prettier --write \"app/**/*.{js,ts,tsx}\"",
|
|
13
|
+
"format:services": "prettier --write \"services/**/*.{js,ts,tsx}\"",
|
|
14
|
+
"generate": "orval --config orval.config.ts",
|
|
15
|
+
"generate:api": "npm run generate && npm run format:services && node scripts/fix-generated-types.mjs",
|
|
16
|
+
"dev:full": "npm run generate:api && npm run dev",
|
|
17
|
+
"test": "vitest",
|
|
18
|
+
"test:run": "vitest run"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@hookform/resolvers": "^5.4.0",
|
|
22
|
+
"@radix-ui/react-label": "^2.1.10",
|
|
23
|
+
"@radix-ui/react-slot": "^1.3.0",
|
|
24
|
+
"@tanstack/react-query": "^5.101.1",
|
|
25
|
+
"@tanstack/react-query-devtools": "^5.101.1",
|
|
26
|
+
"axios": "^1.18.1",
|
|
27
|
+
"class-variance-authority": "^0.7.1",
|
|
28
|
+
"clsx": "^2.1.1",
|
|
29
|
+
"lucide-react": "^1.21.0",
|
|
30
|
+
"next": "^16.2.9",
|
|
31
|
+
"next-themes": "^0.4.6",
|
|
32
|
+
"react": "19.2.7",
|
|
33
|
+
"react-dom": "19.2.7",
|
|
34
|
+
"react-hook-form": "^7.80.0",
|
|
35
|
+
"sonner": "^2.0.7",
|
|
36
|
+
"tailwind-merge": "^3.6.0",
|
|
37
|
+
"zod": "^4.4.3",
|
|
38
|
+
"zustand": "^5.0.14"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@tailwindcss/postcss": "^4",
|
|
42
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
43
|
+
"@testing-library/react": "^16.3.2",
|
|
44
|
+
"@types/node": "^26",
|
|
45
|
+
"@types/react": "^19",
|
|
46
|
+
"@types/react-dom": "^19",
|
|
47
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
48
|
+
"eslint": "^10",
|
|
49
|
+
"eslint-config-next": "^16.2.9",
|
|
50
|
+
"eslint-config-prettier": "^10.1.8",
|
|
51
|
+
"figlet": "^1.11.0",
|
|
52
|
+
"husky": "^9.1.7",
|
|
53
|
+
"jsdom": "^29.1.1",
|
|
54
|
+
"msw": "^2.14.6",
|
|
55
|
+
"orval": "^8.19.0",
|
|
56
|
+
"prettier": "^3.8.4",
|
|
57
|
+
"tailwindcss": "^4",
|
|
58
|
+
"tw-animate-css": "^1.4.0",
|
|
59
|
+
"typescript": "6.0.3",
|
|
60
|
+
"vitest": "^4.1.9"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
plugins: {
|
|
3
|
-
"@tailwindcss/postcss": {},
|
|
4
|
-
},
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export default config;
|
|
1
|
+
const config = {
|
|
2
|
+
plugins: {
|
|
3
|
+
"@tailwindcss/postcss": {},
|
|
4
|
+
},
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export default config;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// Post-processing hook for orval output.
|
|
2
|
-
// Runs after `npm run generate`. Add codemods here if your backend schema needs
|
|
3
|
-
// tweaks the generator can't express. No-op when nothing is generated yet.
|
|
4
|
-
import { existsSync } from 'node:fs';
|
|
5
|
-
|
|
6
|
-
const GENERATED_DIR = new URL('../services/generated/', import.meta.url);
|
|
7
|
-
|
|
8
|
-
if (!existsSync(GENERATED_DIR)) {
|
|
9
|
-
console.log('fix-generated-types: services/generated yox, keçildi.');
|
|
10
|
-
process.exit(0);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
console.log('fix-generated-types: generated tipləri yoxlandı (no-op).');
|
|
1
|
+
// Post-processing hook for orval output.
|
|
2
|
+
// Runs after `npm run generate`. Add codemods here if your backend schema needs
|
|
3
|
+
// tweaks the generator can't express. No-op when nothing is generated yet.
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
|
|
6
|
+
const GENERATED_DIR = new URL('../services/generated/', import.meta.url);
|
|
7
|
+
|
|
8
|
+
if (!existsSync(GENERATED_DIR)) {
|
|
9
|
+
console.log('fix-generated-types: services/generated yox, keçildi.');
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
console.log('fix-generated-types: generated tipləri yoxlandı (no-op).');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# orval writes generated react-query hooks + models here.
|
|
2
|
-
# Run `npm run generate:api` after pointing orval.config.ts at your schema.
|
|
1
|
+
# orval writes generated react-query hooks + models here.
|
|
2
|
+
# Run `npm run generate:api` after pointing orval.config.ts at your schema.
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { toast } from 'sonner';
|
|
3
|
-
import { useUserStore } from '@/store/user-store';
|
|
4
|
-
import { env } from '@/config/env';
|
|
5
|
-
import { AXIOS_TIMEOUT_MS } from '@/config/constants';
|
|
6
|
-
import { paramsSerializer } from '@/lib/paramsSerializer';
|
|
7
|
-
|
|
8
|
-
export const httpClient: AxiosInstance = axios.create({
|
|
9
|
-
baseURL: env.apiBaseUrl,
|
|
10
|
-
withCredentials: true,
|
|
11
|
-
paramsSerializer,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
httpClient.defaults.timeout = AXIOS_TIMEOUT_MS;
|
|
15
|
-
|
|
16
|
-
type ServerErrorData = { message: string };
|
|
17
|
-
|
|
18
|
-
const errorMessageByCode: Record<number, string> = {
|
|
19
|
-
400: 'Validation error',
|
|
20
|
-
404: 'Not found',
|
|
21
|
-
500: 'Server error',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const setupInterceptors = () => {
|
|
25
|
-
httpClient.interceptors.request.use(
|
|
26
|
-
(requestConfig) => {
|
|
27
|
-
if (typeof window !== 'undefined') {
|
|
28
|
-
const locale =
|
|
29
|
-
document.cookie.match(/NEXT_LOCALE=([^;]+)/)?.[1] ?? 'az';
|
|
30
|
-
requestConfig.headers['Accept-Language'] = locale;
|
|
31
|
-
}
|
|
32
|
-
return requestConfig;
|
|
33
|
-
},
|
|
34
|
-
(error: AxiosError) => Promise.reject(error),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
httpClient.interceptors.response.use(
|
|
38
|
-
(response: AxiosResponse) => response,
|
|
39
|
-
(error: AxiosError) => {
|
|
40
|
-
if (error.response) {
|
|
41
|
-
const errorStatus = error.response.status;
|
|
42
|
-
const errorData = error.response.data as ServerErrorData;
|
|
43
|
-
|
|
44
|
-
if (errorStatus === 401 || errorStatus === 403) {
|
|
45
|
-
const store = useUserStore.getState();
|
|
46
|
-
if (store.isAuthenticated()) {
|
|
47
|
-
store.clearUser();
|
|
48
|
-
window.dispatchEvent(new CustomEvent('auth:unauthorized'));
|
|
49
|
-
}
|
|
50
|
-
return Promise.reject(error);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (errorStatus in errorMessageByCode) {
|
|
54
|
-
toast.error(errorData?.message ?? errorMessageByCode[errorStatus]);
|
|
55
|
-
} else if (errorData?.message) {
|
|
56
|
-
toast.error(errorData.message);
|
|
57
|
-
} else {
|
|
58
|
-
toast.error(`Server status ${errorStatus}`);
|
|
59
|
-
}
|
|
60
|
-
} else if (error.request) {
|
|
61
|
-
toast.error('Network error. Check your connection.');
|
|
62
|
-
} else {
|
|
63
|
-
toast.error(`Unexpected error: ${error.message}`);
|
|
64
|
-
}
|
|
65
|
-
return Promise.reject(error);
|
|
66
|
-
},
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
setupInterceptors();
|
|
1
|
+
import axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
import { toast } from 'sonner';
|
|
3
|
+
import { useUserStore } from '@/store/user-store';
|
|
4
|
+
import { env } from '@/config/env';
|
|
5
|
+
import { AXIOS_TIMEOUT_MS } from '@/config/constants';
|
|
6
|
+
import { paramsSerializer } from '@/lib/paramsSerializer';
|
|
7
|
+
|
|
8
|
+
export const httpClient: AxiosInstance = axios.create({
|
|
9
|
+
baseURL: env.apiBaseUrl,
|
|
10
|
+
withCredentials: true,
|
|
11
|
+
paramsSerializer,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
httpClient.defaults.timeout = AXIOS_TIMEOUT_MS;
|
|
15
|
+
|
|
16
|
+
type ServerErrorData = { message: string };
|
|
17
|
+
|
|
18
|
+
const errorMessageByCode: Record<number, string> = {
|
|
19
|
+
400: 'Validation error',
|
|
20
|
+
404: 'Not found',
|
|
21
|
+
500: 'Server error',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const setupInterceptors = () => {
|
|
25
|
+
httpClient.interceptors.request.use(
|
|
26
|
+
(requestConfig) => {
|
|
27
|
+
if (typeof window !== 'undefined') {
|
|
28
|
+
const locale =
|
|
29
|
+
document.cookie.match(/NEXT_LOCALE=([^;]+)/)?.[1] ?? 'az';
|
|
30
|
+
requestConfig.headers['Accept-Language'] = locale;
|
|
31
|
+
}
|
|
32
|
+
return requestConfig;
|
|
33
|
+
},
|
|
34
|
+
(error: AxiosError) => Promise.reject(error),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
httpClient.interceptors.response.use(
|
|
38
|
+
(response: AxiosResponse) => response,
|
|
39
|
+
(error: AxiosError) => {
|
|
40
|
+
if (error.response) {
|
|
41
|
+
const errorStatus = error.response.status;
|
|
42
|
+
const errorData = error.response.data as ServerErrorData;
|
|
43
|
+
|
|
44
|
+
if (errorStatus === 401 || errorStatus === 403) {
|
|
45
|
+
const store = useUserStore.getState();
|
|
46
|
+
if (store.isAuthenticated()) {
|
|
47
|
+
store.clearUser();
|
|
48
|
+
window.dispatchEvent(new CustomEvent('auth:unauthorized'));
|
|
49
|
+
}
|
|
50
|
+
return Promise.reject(error);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (errorStatus in errorMessageByCode) {
|
|
54
|
+
toast.error(errorData?.message ?? errorMessageByCode[errorStatus]);
|
|
55
|
+
} else if (errorData?.message) {
|
|
56
|
+
toast.error(errorData.message);
|
|
57
|
+
} else {
|
|
58
|
+
toast.error(`Server status ${errorStatus}`);
|
|
59
|
+
}
|
|
60
|
+
} else if (error.request) {
|
|
61
|
+
toast.error('Network error. Check your connection.');
|
|
62
|
+
} else {
|
|
63
|
+
toast.error(`Unexpected error: ${error.message}`);
|
|
64
|
+
}
|
|
65
|
+
return Promise.reject(error);
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
setupInterceptors();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { httpClient } from './httpClient';
|
|
3
|
-
|
|
4
|
-
export const customMutator = <T>(config: AxiosRequestConfig): Promise<T> => {
|
|
5
|
-
const { signal, ...rest } = config;
|
|
6
|
-
return httpClient({
|
|
7
|
-
...rest,
|
|
8
|
-
...(signal instanceof AbortSignal ? { signal } : {}),
|
|
9
|
-
}).then(({ data }) => data);
|
|
10
|
-
};
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { httpClient } from './httpClient';
|
|
3
|
+
|
|
4
|
+
export const customMutator = <T>(config: AxiosRequestConfig): Promise<T> => {
|
|
5
|
+
const { signal, ...rest } = config;
|
|
6
|
+
return httpClient({
|
|
7
|
+
...rest,
|
|
8
|
+
...(signal instanceof AbortSignal ? { signal } : {}),
|
|
9
|
+
}).then(({ data }) => data);
|
|
10
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { create } from 'zustand';
|
|
2
|
-
|
|
3
|
-
type CounterState = {
|
|
4
|
-
count: number;
|
|
5
|
-
increment: () => void;
|
|
6
|
-
decrement: () => void;
|
|
7
|
-
reset: () => void;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Minimal store to show the non-persisted pattern. Delete or replace.
|
|
11
|
-
export const useExampleStore = create<CounterState>((set) => ({
|
|
12
|
-
count: 0,
|
|
13
|
-
increment: () => set((s) => ({ count: s.count + 1 })),
|
|
14
|
-
decrement: () => set((s) => ({ count: s.count - 1 })),
|
|
15
|
-
reset: () => set({ count: 0 }),
|
|
16
|
-
}));
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
|
|
3
|
+
type CounterState = {
|
|
4
|
+
count: number;
|
|
5
|
+
increment: () => void;
|
|
6
|
+
decrement: () => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Minimal store to show the non-persisted pattern. Delete or replace.
|
|
11
|
+
export const useExampleStore = create<CounterState>((set) => ({
|
|
12
|
+
count: 0,
|
|
13
|
+
increment: () => set((s) => ({ count: s.count + 1 })),
|
|
14
|
+
decrement: () => set((s) => ({ count: s.count - 1 })),
|
|
15
|
+
reset: () => set({ count: 0 }),
|
|
16
|
+
}));
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { create } from 'zustand';
|
|
2
|
-
import { persist } from 'zustand/middleware';
|
|
3
|
-
|
|
4
|
-
export type User = {
|
|
5
|
-
id: string;
|
|
6
|
-
email: string;
|
|
7
|
-
fullName?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type UserState = {
|
|
11
|
-
user: User | null;
|
|
12
|
-
setUser: (value: User | null) => void;
|
|
13
|
-
clearUser: () => void;
|
|
14
|
-
isAuthenticated: () => boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const useUserStore = create<UserState>()(
|
|
18
|
-
persist(
|
|
19
|
-
(set, get) => ({
|
|
20
|
-
user: null,
|
|
21
|
-
setUser: (value) => set({ user: value }),
|
|
22
|
-
clearUser: () => set({ user: null }),
|
|
23
|
-
isAuthenticated: () => get().user !== null,
|
|
24
|
-
}),
|
|
25
|
-
{
|
|
26
|
-
name: 'user_authenticated',
|
|
27
|
-
},
|
|
28
|
-
),
|
|
29
|
-
);
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { persist } from 'zustand/middleware';
|
|
3
|
+
|
|
4
|
+
export type User = {
|
|
5
|
+
id: string;
|
|
6
|
+
email: string;
|
|
7
|
+
fullName?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type UserState = {
|
|
11
|
+
user: User | null;
|
|
12
|
+
setUser: (value: User | null) => void;
|
|
13
|
+
clearUser: () => void;
|
|
14
|
+
isAuthenticated: () => boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const useUserStore = create<UserState>()(
|
|
18
|
+
persist(
|
|
19
|
+
(set, get) => ({
|
|
20
|
+
user: null,
|
|
21
|
+
setUser: (value) => set({ user: value }),
|
|
22
|
+
clearUser: () => set({ user: null }),
|
|
23
|
+
isAuthenticated: () => get().user !== null,
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
name: 'user_authenticated',
|
|
27
|
+
},
|
|
28
|
+
),
|
|
29
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { http, HttpResponse } from 'msw';
|
|
2
|
-
|
|
3
|
-
// Add request handlers here. Example:
|
|
4
|
-
export const handlers = [
|
|
5
|
-
http.get('*/health', () => HttpResponse.json({ status: 'ok' })),
|
|
6
|
-
];
|
|
1
|
+
import { http, HttpResponse } from 'msw';
|
|
2
|
+
|
|
3
|
+
// Add request handlers here. Example:
|
|
4
|
+
export const handlers = [
|
|
5
|
+
http.get('*/health', () => HttpResponse.json({ status: 'ok' })),
|
|
6
|
+
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { setupServer } from 'msw/node';
|
|
2
|
-
import { handlers } from './handlers';
|
|
3
|
-
|
|
4
|
-
export const server = setupServer(...handlers);
|
|
1
|
+
import { setupServer } from 'msw/node';
|
|
2
|
+
import { handlers } from './handlers';
|
|
3
|
+
|
|
4
|
+
export const server = setupServer(...handlers);
|
package/template2/tsconfig.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2017",
|
|
4
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
-
"allowJs": true,
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"noEmit": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"module": "esnext",
|
|
11
|
-
"moduleResolution": "bundler",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"jsx": "react-jsx",
|
|
15
|
-
"incremental": true,
|
|
16
|
-
"plugins": [
|
|
17
|
-
{
|
|
18
|
-
"name": "next"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"paths": {
|
|
22
|
-
"@/*": ["./*"]
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"include": [
|
|
26
|
-
"next-env.d.ts",
|
|
27
|
-
"**/*.ts",
|
|
28
|
-
"**/*.tsx",
|
|
29
|
-
".next/types/**/*.ts",
|
|
30
|
-
".next/dev/types/**/*.ts",
|
|
31
|
-
"**/*.mts"
|
|
32
|
-
],
|
|
33
|
-
"exclude": ["node_modules"]
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"next-env.d.ts",
|
|
27
|
+
"**/*.ts",
|
|
28
|
+
"**/*.tsx",
|
|
29
|
+
".next/types/**/*.ts",
|
|
30
|
+
".next/dev/types/**/*.ts",
|
|
31
|
+
"**/*.mts"
|
|
32
|
+
],
|
|
33
|
+
"exclude": ["node_modules"]
|
|
34
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
import react from "@vitejs/plugin-react";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [react()],
|
|
7
|
-
test: {
|
|
8
|
-
environment: "jsdom",
|
|
9
|
-
globals: true,
|
|
10
|
-
setupFiles: ["./vitest.setup.ts"],
|
|
11
|
-
},
|
|
12
|
-
resolve: {
|
|
13
|
-
alias: {
|
|
14
|
-
"@": path.resolve(__dirname, "."),
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
test: {
|
|
8
|
+
environment: "jsdom",
|
|
9
|
+
globals: true,
|
|
10
|
+
setupFiles: ["./vitest.setup.ts"],
|
|
11
|
+
},
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
"@": path.resolve(__dirname, "."),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "@testing-library/jest-dom";
|
|
2
|
-
import { server } from "./testing/msw/server";
|
|
3
|
-
import { beforeAll, afterEach, afterAll } from "vitest";
|
|
4
|
-
|
|
5
|
-
beforeAll(() => server.listen({ onUnhandledRequest: "warn" }));
|
|
6
|
-
afterEach(() => server.resetHandlers());
|
|
7
|
-
afterAll(() => server.close());
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import { server } from "./testing/msw/server";
|
|
3
|
+
import { beforeAll, afterEach, afterAll } from "vitest";
|
|
4
|
+
|
|
5
|
+
beforeAll(() => server.listen({ onUnhandledRequest: "warn" }));
|
|
6
|
+
afterEach(() => server.resetHandlers());
|
|
7
|
+
afterAll(() => server.close());
|
package/template3/README.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
# Rspack Simple Starter
|
|
2
|
-
|
|
3
|
-
A minimal **React + TypeScript** template bundled with [Rspack](https://rspack.dev/) — a fast Rust-based bundler. Intentionally bare; grow it as you need.
|
|
4
|
-
|
|
5
|
-
## Scripts
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm dev # dev server on http://localhost:5174
|
|
9
|
-
pnpm build # production build → dist/
|
|
10
|
-
pnpm preview # serve the production build
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Structure
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
├── index.html
|
|
17
|
-
├── rspack.config.mjs # entry, swc loader, html plugin, dev server
|
|
18
|
-
├── tsconfig.json
|
|
19
|
-
└── src/
|
|
20
|
-
├── main.tsx # React root
|
|
21
|
-
├── App.tsx
|
|
22
|
-
├── index.css
|
|
23
|
-
└── components/
|
|
24
|
-
└── author-credit.tsx
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
TypeScript/TSX is transpiled by Rspack's built-in SWC loader (no Babel). CSS uses Rspack's native CSS support (`type: "css"`).
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
Built by **Javid Salimov** ·
|
|
32
|
-
[GitHub](https://github.com/javidselimov) ·
|
|
33
|
-
[LinkedIn](https://www.linkedin.com/in/javidsalim/) ·
|
|
34
|
-
[npm](https://www.npmjs.com/~ubuligan)
|
|
1
|
+
# Rspack Simple Starter
|
|
2
|
+
|
|
3
|
+
A minimal **React + TypeScript** template bundled with [Rspack](https://rspack.dev/) — a fast Rust-based bundler. Intentionally bare; grow it as you need.
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm dev # dev server on http://localhost:5174
|
|
9
|
+
pnpm build # production build → dist/
|
|
10
|
+
pnpm preview # serve the production build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
├── index.html
|
|
17
|
+
├── rspack.config.mjs # entry, swc loader, html plugin, dev server
|
|
18
|
+
├── tsconfig.json
|
|
19
|
+
└── src/
|
|
20
|
+
├── main.tsx # React root
|
|
21
|
+
├── App.tsx
|
|
22
|
+
├── index.css
|
|
23
|
+
└── components/
|
|
24
|
+
└── author-credit.tsx
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
TypeScript/TSX is transpiled by Rspack's built-in SWC loader (no Babel). CSS uses Rspack's native CSS support (`type: "css"`).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
Built by **Javid Salimov** ·
|
|
32
|
+
[GitHub](https://github.com/javidselimov) ·
|
|
33
|
+
[LinkedIn](https://www.linkedin.com/in/javidsalim/) ·
|
|
34
|
+
[npm](https://www.npmjs.com/~ubuligan)
|