create-reactivite 1.1.0 → 1.2.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.
Files changed (55) hide show
  1. package/README.md +198 -197
  2. package/index.js +26 -1
  3. package/package.json +4 -3
  4. package/template/_gitignore +24 -0
  5. package/template2/.env.example +8 -0
  6. package/template2/.husky/pre-commit +4 -0
  7. package/template2/.prettierrc +5 -0
  8. package/template2/README.md +73 -0
  9. package/template2/__tests__/example.test.ts +20 -0
  10. package/template2/_gitignore +37 -0
  11. package/template2/app/[locale]/(private)/dashboard/page.tsx +52 -0
  12. package/template2/app/[locale]/(public)/login/page.tsx +83 -0
  13. package/template2/app/[locale]/layout.tsx +56 -0
  14. package/template2/app/[locale]/locales.ts +10 -0
  15. package/template2/app/[locale]/page.tsx +38 -0
  16. package/template2/app/api/clear-session/route.ts +10 -0
  17. package/template2/app/globals.css +127 -0
  18. package/template2/app/layout.tsx +7 -0
  19. package/template2/app/page.tsx +6 -0
  20. package/template2/components/AuthEventListener.tsx +22 -0
  21. package/template2/components/theme-provider.tsx +78 -0
  22. package/template2/components/ui/button.tsx +60 -0
  23. package/template2/components/ui/card.tsx +92 -0
  24. package/template2/components/ui/input.tsx +21 -0
  25. package/template2/components/ui/label.tsx +24 -0
  26. package/template2/components/ui/sonner.tsx +40 -0
  27. package/template2/components.json +22 -0
  28. package/template2/config/constants.ts +7 -0
  29. package/template2/config/env.ts +5 -0
  30. package/template2/contexts/translation-context.tsx +70 -0
  31. package/template2/eslint.config.mjs +18 -0
  32. package/template2/hoc/provider.tsx +27 -0
  33. package/template2/lib/paramsSerializer.ts +40 -0
  34. package/template2/lib/utils.ts +6 -0
  35. package/template2/locales/az.json +20 -0
  36. package/template2/locales/en.json +20 -0
  37. package/template2/next-env.d.ts +6 -0
  38. package/template2/next.config.ts +17 -0
  39. package/template2/orval.config.ts +66 -0
  40. package/template2/package.json +62 -0
  41. package/template2/pnpm-lock.yaml +6804 -0
  42. package/template2/postcss.config.mjs +7 -0
  43. package/template2/public/.gitkeep +0 -0
  44. package/template2/scripts/fix-generated-types.mjs +13 -0
  45. package/template2/services/generated/.gitkeep +2 -0
  46. package/template2/services/httpClient/httpClient.ts +70 -0
  47. package/template2/services/httpClient/orvalMutator.ts +10 -0
  48. package/template2/store/example-store.tsx +16 -0
  49. package/template2/store/user-store.tsx +29 -0
  50. package/template2/testing/msw/handlers/index.ts +6 -0
  51. package/template2/testing/msw/server.ts +4 -0
  52. package/template2/tsconfig.json +34 -0
  53. package/template2/tsconfig.tsbuildinfo +1 -0
  54. package/template2/vitest.config.ts +17 -0
  55. package/template2/vitest.setup.ts +7 -0
@@ -0,0 +1,24 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as LabelPrimitive from "@radix-ui/react-label"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ function Label({
9
+ className,
10
+ ...props
11
+ }: React.ComponentProps<typeof LabelPrimitive.Root>) {
12
+ return (
13
+ <LabelPrimitive.Root
14
+ data-slot="label"
15
+ className={cn(
16
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ )
22
+ }
23
+
24
+ export { Label }
@@ -0,0 +1,40 @@
1
+ "use client"
2
+
3
+ import {
4
+ CircleCheckIcon,
5
+ InfoIcon,
6
+ Loader2Icon,
7
+ OctagonXIcon,
8
+ TriangleAlertIcon,
9
+ } from "lucide-react"
10
+ import { useTheme } from "next-themes"
11
+ import { Toaster as Sonner, type ToasterProps } from "sonner"
12
+
13
+ const Toaster = ({ ...props }: ToasterProps) => {
14
+ const { theme = "system" } = useTheme()
15
+
16
+ return (
17
+ <Sonner
18
+ theme={theme as ToasterProps["theme"]}
19
+ className="toaster group"
20
+ icons={{
21
+ success: <CircleCheckIcon className="size-4" />,
22
+ info: <InfoIcon className="size-4" />,
23
+ warning: <TriangleAlertIcon className="size-4" />,
24
+ error: <OctagonXIcon className="size-4" />,
25
+ loading: <Loader2Icon className="size-4 animate-spin" />,
26
+ }}
27
+ style={
28
+ {
29
+ "--normal-bg": "var(--popover)",
30
+ "--normal-text": "var(--popover-foreground)",
31
+ "--normal-border": "var(--border)",
32
+ "--border-radius": "var(--radius)",
33
+ } as React.CSSProperties
34
+ }
35
+ {...props}
36
+ />
37
+ )
38
+ }
39
+
40
+ export { Toaster }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": true,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "app/globals.css",
9
+ "baseColor": "slate",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "iconLibrary": "lucide",
14
+ "aliases": {
15
+ "components": "@/components",
16
+ "utils": "@/lib/utils",
17
+ "ui": "@/components/ui",
18
+ "lib": "@/lib",
19
+ "hooks": "@/lib/hooks"
20
+ },
21
+ "registries": {}
22
+ }
@@ -0,0 +1,7 @@
1
+ export const LOCALES = ['az', 'en'] as const;
2
+ export type Locale = (typeof LOCALES)[number];
3
+ export const DEFAULT_LOCALE: Locale = 'az';
4
+
5
+ export const DEFAULT_PAGE_SIZE = 9;
6
+ export const QUERY_STALE_TIME_TAGS = 5 * 60 * 1000;
7
+ export const AXIOS_TIMEOUT_MS = 15000;
@@ -0,0 +1,5 @@
1
+ export const env = {
2
+ apiBaseUrl: process.env.NEXT_PUBLIC_API_BASE_URL ?? '/api/backend',
3
+ apiBaseUrlServer: process.env.API_BASE_URL,
4
+ nodeEnv: process.env.NODE_ENV ?? 'development',
5
+ } as const;
@@ -0,0 +1,70 @@
1
+ 'use client';
2
+
3
+ import { createContext, useContext, ReactNode, useMemo } from 'react';
4
+
5
+ type MessageValue = string | Record<string, string>;
6
+ type Messages = Record<string, MessageValue>;
7
+
8
+ interface TranslationContextType {
9
+ locale: string;
10
+ messages: Messages;
11
+ }
12
+
13
+ const TranslationContext = createContext<TranslationContextType | undefined>(
14
+ undefined,
15
+ );
16
+
17
+ interface TranslationProviderProps {
18
+ children: ReactNode;
19
+ locale: string;
20
+ messages: Messages;
21
+ }
22
+
23
+ export function TranslationProvider({
24
+ children,
25
+ locale,
26
+ messages,
27
+ }: Readonly<TranslationProviderProps>) {
28
+ const value = useMemo(() => ({ locale, messages }), [locale, messages]);
29
+
30
+ return (
31
+ <TranslationContext.Provider value={value}>
32
+ {children}
33
+ </TranslationContext.Provider>
34
+ );
35
+ }
36
+
37
+ export function useTranslations(namespace?: string) {
38
+ const context = useContext(TranslationContext);
39
+
40
+ if (!context) {
41
+ throw new Error('useTranslations must be used within TranslationProvider');
42
+ }
43
+
44
+ return (key: string): string => {
45
+ const { messages } = context;
46
+
47
+ if (!namespace) {
48
+ const value = messages[key];
49
+ return typeof value === 'string' ? value : key;
50
+ }
51
+
52
+ const ns = messages[namespace];
53
+
54
+ if (!ns || typeof ns !== 'object') {
55
+ return key;
56
+ }
57
+
58
+ return ns[key] ?? key;
59
+ };
60
+ }
61
+
62
+ export function useLocale(): string {
63
+ const context = useContext(TranslationContext);
64
+
65
+ if (!context) {
66
+ throw new Error('useLocale must be used within TranslationProvider');
67
+ }
68
+
69
+ return context.locale;
70
+ }
@@ -0,0 +1,18 @@
1
+ import { defineConfig, globalIgnores } from "eslint/config";
2
+ import nextVitals from "eslint-config-next/core-web-vitals";
3
+ import nextTs from "eslint-config-next/typescript";
4
+
5
+ const eslintConfig = defineConfig([
6
+ ...nextVitals,
7
+ ...nextTs,
8
+ globalIgnores([
9
+ ".next/**",
10
+ "out/**",
11
+ "build/**",
12
+ "next-env.d.ts",
13
+ // Auto-generated by orval — do not lint
14
+ "services/generated/**",
15
+ ]),
16
+ ]);
17
+
18
+ export default eslintConfig;
@@ -0,0 +1,27 @@
1
+ 'use client';
2
+
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
5
+ import { useState } from 'react';
6
+
7
+ export function QueryProvider({
8
+ children,
9
+ }: Readonly<{ children: React.ReactNode }>) {
10
+ const [queryClient] = useState(
11
+ () =>
12
+ new QueryClient({
13
+ defaultOptions: {
14
+ queries: {
15
+ staleTime: 0,
16
+ },
17
+ },
18
+ }),
19
+ );
20
+
21
+ return (
22
+ <QueryClientProvider client={queryClient}>
23
+ {children}
24
+ <ReactQueryDevtools initialIsOpen={false} />
25
+ </QueryClientProvider>
26
+ );
27
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Flattens one level of nested objects before serializing to a query string.
3
+ * Useful when a backend (e.g. Spring Boot Pageable / @ModelAttribute) expects
4
+ * flat params (page=0&size=10) instead of Axios's default bracket notation
5
+ * (pageable[page]=0&pageable[size]=10).
6
+ *
7
+ * Arrays at any level are repeated: sort=name,asc&sort=id,desc
8
+ * null/undefined values are omitted.
9
+ */
10
+ export const paramsSerializer = (params: Record<string, unknown>): string => {
11
+ const parts: string[] = [];
12
+ for (const [key, value] of Object.entries(params)) {
13
+ if (value === undefined || value === null) continue;
14
+ if (typeof value === 'object' && !Array.isArray(value)) {
15
+ for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
16
+ if (v === undefined || v === null) continue;
17
+ if (Array.isArray(v)) {
18
+ for (const item of v)
19
+ parts.push(
20
+ `${encodeURIComponent(k)}=${encodeURIComponent(String(item))}`,
21
+ );
22
+ } else {
23
+ parts.push(
24
+ `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`,
25
+ );
26
+ }
27
+ }
28
+ } else if (Array.isArray(value)) {
29
+ for (const item of value)
30
+ parts.push(
31
+ `${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`,
32
+ );
33
+ } else {
34
+ parts.push(
35
+ `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`,
36
+ );
37
+ }
38
+ }
39
+ return parts.join('&');
40
+ };
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "home": {
3
+ "title": "Nextivite-ə xoş gəlmisən",
4
+ "subtitle": "Next.js 16, Tailwind v4, TanStack Query, Zustand, orval və husky ilə hazır boilerplate.",
5
+ "login": "Daxil ol",
6
+ "dashboard": "Panelə keç"
7
+ },
8
+ "login": {
9
+ "title": "Daxil ol",
10
+ "email": "E-poçt",
11
+ "password": "Şifrə",
12
+ "submit": "Daxil ol",
13
+ "success": "Uğurla daxil oldun"
14
+ },
15
+ "dashboard": {
16
+ "title": "Panel",
17
+ "welcome": "Xoş gəldin",
18
+ "logout": "Çıxış"
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "home": {
3
+ "title": "Welcome to Nextivite",
4
+ "subtitle": "A ready-to-go boilerplate with Next.js 16, Tailwind v4, TanStack Query, Zustand, orval and husky.",
5
+ "login": "Sign in",
6
+ "dashboard": "Go to dashboard"
7
+ },
8
+ "login": {
9
+ "title": "Sign in",
10
+ "email": "Email",
11
+ "password": "Password",
12
+ "submit": "Sign in",
13
+ "success": "Signed in successfully"
14
+ },
15
+ "dashboard": {
16
+ "title": "Dashboard",
17
+ "welcome": "Welcome",
18
+ "logout": "Log out"
19
+ }
20
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+ import "./.next/types/routes.d.ts";
4
+
5
+ // NOTE: This file should not be edited
6
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -0,0 +1,17 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ async rewrites() {
5
+ const backendUrl = process.env.API_BASE_URL;
6
+ if (!backendUrl) return [];
7
+ return [
8
+ {
9
+ source: "/api/backend/:path*",
10
+ destination: `${backendUrl}/:path*`,
11
+ },
12
+ ];
13
+ },
14
+ output: "standalone",
15
+ };
16
+
17
+ export default nextConfig;
@@ -0,0 +1,66 @@
1
+ import { defineConfig } from 'orval';
2
+
3
+ const SKIP = new Set(['public', 'api', 'v1', 'v2', 'v3']);
4
+ const VERB_PREFIX: Record<string, string> = {
5
+ get: 'get',
6
+ post: 'create',
7
+ put: 'update',
8
+ patch: 'patch',
9
+ delete: 'delete',
10
+ };
11
+
12
+ // Converts path + HTTP verb → semantic camelCase name.
13
+ // GET /users/public/{id}/posts → getUsersByIdPosts
14
+ // POST /public/auth/login → createAuthLogin
15
+ export function buildOperationName(
16
+ _operation: unknown,
17
+ route: string,
18
+ verb: string,
19
+ ): string {
20
+ const prefix = VERB_PREFIX[verb] ?? verb;
21
+ const parts = route
22
+ .replace(/\{([^}]+)\}/g, (_, p) =>
23
+ 'By' + p.charAt(0).toUpperCase() + p.slice(1),
24
+ )
25
+ .split('/')
26
+ .filter((s) => s && !SKIP.has(s))
27
+ .map((s) =>
28
+ s
29
+ .charAt(0)
30
+ .toUpperCase()
31
+ .concat(s.slice(1))
32
+ .replace(/-([a-z])/g, (_, c) => c.toUpperCase()),
33
+ );
34
+
35
+ const deduped = parts.filter((p, i) => p !== parts[i - 1]);
36
+ return prefix + deduped.join('');
37
+ }
38
+
39
+ export default defineConfig({
40
+ api: {
41
+ input: {
42
+ // Replace with your OpenAPI/Swagger schema URL or local file path.
43
+ target: process.env.OPENAPI_TARGET ?? 'http://localhost:8080/v3/api-docs',
44
+ },
45
+ output: {
46
+ mode: 'tags-split',
47
+ target: 'services/generated',
48
+ schemas: 'services/generated/model',
49
+ client: 'react-query',
50
+ httpClient: 'axios',
51
+ baseUrl: process.env.NEXT_PUBLIC_API_BASE_URL,
52
+ override: {
53
+ operationName: buildOperationName,
54
+ mutator: {
55
+ path: 'services/httpClient/orvalMutator.ts',
56
+ name: 'customMutator',
57
+ },
58
+ query: {
59
+ useQuery: true,
60
+ useMutation: true,
61
+ signal: true,
62
+ },
63
+ },
64
+ },
65
+ },
66
+ });
@@ -0,0 +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.2.2",
22
+ "@radix-ui/react-label": "^2.1.8",
23
+ "@radix-ui/react-slot": "^1.2.4",
24
+ "@tanstack/react-query": "^5.90.8",
25
+ "@tanstack/react-query-devtools": "^5.90.2",
26
+ "axios": "^1.13.2",
27
+ "class-variance-authority": "^0.7.1",
28
+ "clsx": "^2.1.1",
29
+ "lucide-react": "^0.548.0",
30
+ "next": "^16.2.2",
31
+ "next-themes": "^0.4.6",
32
+ "react": "19.2.0",
33
+ "react-dom": "19.2.0",
34
+ "react-hook-form": "^7.66.0",
35
+ "sonner": "^2.0.7",
36
+ "tailwind-merge": "^3.3.1",
37
+ "zod": "^4.1.12",
38
+ "zustand": "^5.0.8"
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": "^20",
45
+ "@types/react": "^19",
46
+ "@types/react-dom": "^19",
47
+ "@vitejs/plugin-react": "^6.0.2",
48
+ "eslint": "^9",
49
+ "eslint-config-next": "^16.2.2",
50
+ "eslint-config-prettier": "^10.1.8",
51
+ "figlet": "^1.9.3",
52
+ "husky": "^9.1.7",
53
+ "jsdom": "^29.1.1",
54
+ "msw": "^2.14.6",
55
+ "orval": "^8.12.3",
56
+ "prettier": "^3.6.2",
57
+ "tailwindcss": "^4",
58
+ "tw-animate-css": "^1.4.0",
59
+ "typescript": "5.9.3",
60
+ "vitest": "^4.1.7"
61
+ }
62
+ }