create-fe-boilerplate 0.3.2 → 0.4.1

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 (110) hide show
  1. package/bin/index.js +1 -1
  2. package/package.json +1 -1
  3. package/templates/react/js/scss/axios/README.md +73 -0
  4. package/templates/react/js/scss/axios/eslint.config.js +23 -0
  5. package/templates/react/js/scss/axios/index.html +13 -0
  6. package/templates/react/js/scss/axios/package-lock.json +4517 -0
  7. package/templates/react/js/scss/axios/package.json +35 -0
  8. package/templates/react/js/scss/axios/public/vite.svg +1 -0
  9. package/templates/react/js/scss/axios/react-ts-tailwind-axios/.env.example +1 -0
  10. package/templates/react/js/scss/axios/src/App.css +0 -0
  11. package/templates/react/js/scss/axios/src/App.jsx +14 -0
  12. package/templates/react/js/scss/axios/src/api/axios.js +201 -0
  13. package/templates/react/js/scss/axios/src/component/auth/VerifyOtpModal.jsx +60 -0
  14. package/templates/react/js/scss/axios/src/component/common/ui/Toast/Toast.js +58 -0
  15. package/templates/react/js/scss/axios/src/contants/constants.js +45 -0
  16. package/templates/react/js/scss/axios/src/index.css +4 -0
  17. package/templates/react/js/scss/axios/src/main.jsx +12 -0
  18. package/templates/react/js/scss/axios/src/pages/Auth.scss +203 -0
  19. package/templates/react/js/scss/axios/src/pages/Dashboard.jsx +10 -0
  20. package/templates/react/js/scss/axios/src/pages/Login.jsx +69 -0
  21. package/templates/react/js/scss/axios/src/pages/Signup.jsx +74 -0
  22. package/templates/react/js/scss/axios/src/router/AppRoutes.jsx +19 -0
  23. package/templates/react/js/scss/axios/src/styles/global.scss +5 -0
  24. package/templates/react/js/scss/axios/src/utils/utils.js +58 -0
  25. package/templates/react/js/scss/axios/tsconfig.app.json +28 -0
  26. package/templates/react/js/scss/axios/vite.config.js +7 -0
  27. package/templates/react/js/scss/rtk/README.md +73 -0
  28. package/templates/react/js/scss/rtk/eslint.config.js +23 -0
  29. package/templates/react/js/scss/rtk/index.html +13 -0
  30. package/templates/react/js/scss/rtk/package-lock.json +4208 -0
  31. package/templates/react/js/scss/rtk/package.json +35 -0
  32. package/templates/react/js/scss/rtk/public/vite.svg +1 -0
  33. package/templates/react/js/scss/rtk/react-ts-tailwind-axios/.env.example +1 -0
  34. package/templates/react/js/scss/rtk/src/App.css +0 -0
  35. package/templates/react/js/scss/rtk/src/App.jsx +14 -0
  36. package/templates/react/js/scss/rtk/src/api/axios.js +201 -0
  37. package/templates/react/js/scss/rtk/src/component/auth/VerifyOtpModal.jsx +61 -0
  38. package/templates/react/js/scss/rtk/src/component/auth/VerifyOtpModal.scss +62 -0
  39. package/templates/react/js/scss/rtk/src/component/common/ui/Toast/Toast.js +58 -0
  40. package/templates/react/js/scss/rtk/src/contants/constants.js +45 -0
  41. package/templates/react/js/scss/rtk/src/main.jsx +16 -0
  42. package/templates/react/js/scss/rtk/src/pages/Dashboard.jsx +12 -0
  43. package/templates/react/js/scss/rtk/src/pages/Dashboard.scss +13 -0
  44. package/templates/react/js/scss/rtk/src/pages/Login.jsx +75 -0
  45. package/templates/react/js/scss/rtk/src/pages/Login.scss +67 -0
  46. package/templates/react/js/scss/rtk/src/pages/Signup.jsx +73 -0
  47. package/templates/react/js/scss/rtk/src/pages/Signup.scss +66 -0
  48. package/templates/react/js/scss/rtk/src/router/AppRoutes.jsx +19 -0
  49. package/templates/react/js/scss/rtk/src/store/index.js +10 -0
  50. package/templates/react/js/scss/rtk/src/store/services/api.js +34 -0
  51. package/templates/react/js/scss/rtk/src/styles/global.scss +10 -0
  52. package/templates/react/js/scss/rtk/src/utils/utils.js +59 -0
  53. package/templates/react/js/scss/rtk/tsconfig.app.json +28 -0
  54. package/templates/react/js/scss/rtk/vite.config.js +7 -0
  55. package/templates/react/ts/scss/axios/README.md +73 -0
  56. package/templates/react/ts/scss/axios/eslint.config.js +23 -0
  57. package/templates/react/ts/scss/axios/index.html +13 -0
  58. package/templates/react/ts/scss/axios/package-lock.json +4868 -0
  59. package/templates/react/ts/scss/axios/package.json +39 -0
  60. package/templates/react/ts/scss/axios/public/vite.svg +1 -0
  61. package/templates/react/ts/scss/axios/react-ts-tailwind-axios/.env.example +1 -0
  62. package/templates/react/ts/scss/axios/src/App.css +0 -0
  63. package/templates/react/ts/scss/axios/src/App.tsx +14 -0
  64. package/templates/react/ts/scss/axios/src/api/axios.ts +236 -0
  65. package/templates/react/ts/scss/axios/src/component/auth/VerifyOtpModal.tsx +70 -0
  66. package/templates/react/ts/scss/axios/src/component/common/ui/Toast/Toast.ts +58 -0
  67. package/templates/react/ts/scss/axios/src/contants/constants.ts +45 -0
  68. package/templates/react/ts/scss/axios/src/index.css +4 -0
  69. package/templates/react/ts/scss/axios/src/main.tsx +10 -0
  70. package/templates/react/ts/scss/axios/src/pages/Auth.scss +203 -0
  71. package/templates/react/ts/scss/axios/src/pages/Dashboard.tsx +10 -0
  72. package/templates/react/ts/scss/axios/src/pages/Login.tsx +69 -0
  73. package/templates/react/ts/scss/axios/src/pages/Signup.tsx +74 -0
  74. package/templates/react/ts/scss/axios/src/router/AppRoutes.tsx +19 -0
  75. package/templates/react/ts/scss/axios/src/styles/global.scss +5 -0
  76. package/templates/react/ts/scss/axios/src/utils/utils.ts +59 -0
  77. package/templates/react/ts/scss/axios/tsconfig.app.json +28 -0
  78. package/templates/react/ts/scss/axios/tsconfig.json +12 -0
  79. package/templates/react/ts/scss/axios/tsconfig.node.json +26 -0
  80. package/templates/react/ts/scss/axios/vite.config.ts +7 -0
  81. package/templates/react/ts/scss/rtk/README.md +73 -0
  82. package/templates/react/ts/scss/rtk/eslint.config.js +23 -0
  83. package/templates/react/ts/scss/rtk/index.html +13 -0
  84. package/templates/react/ts/scss/rtk/package-lock.json +4218 -0
  85. package/templates/react/ts/scss/rtk/package.json +38 -0
  86. package/templates/react/ts/scss/rtk/public/vite.svg +1 -0
  87. package/templates/react/ts/scss/rtk/react-ts-tailwind-axios/.env.example +1 -0
  88. package/templates/react/ts/scss/rtk/src/App.css +0 -0
  89. package/templates/react/ts/scss/rtk/src/App.tsx +14 -0
  90. package/templates/react/ts/scss/rtk/src/api/axios.ts +236 -0
  91. package/templates/react/ts/scss/rtk/src/component/auth/VerifyOtpModal.scss +62 -0
  92. package/templates/react/ts/scss/rtk/src/component/auth/VerifyOtpModal.tsx +71 -0
  93. package/templates/react/ts/scss/rtk/src/component/common/ui/Toast/Toast.ts +58 -0
  94. package/templates/react/ts/scss/rtk/src/contants/constants.ts +45 -0
  95. package/templates/react/ts/scss/rtk/src/main.tsx +14 -0
  96. package/templates/react/ts/scss/rtk/src/pages/Dashboard.scss +13 -0
  97. package/templates/react/ts/scss/rtk/src/pages/Dashboard.tsx +12 -0
  98. package/templates/react/ts/scss/rtk/src/pages/Login.scss +67 -0
  99. package/templates/react/ts/scss/rtk/src/pages/Login.tsx +75 -0
  100. package/templates/react/ts/scss/rtk/src/pages/Signup.scss +66 -0
  101. package/templates/react/ts/scss/rtk/src/pages/Signup.tsx +73 -0
  102. package/templates/react/ts/scss/rtk/src/router/AppRoutes.tsx +19 -0
  103. package/templates/react/ts/scss/rtk/src/store/index.ts +13 -0
  104. package/templates/react/ts/scss/rtk/src/store/services/api.ts +37 -0
  105. package/templates/react/ts/scss/rtk/src/styles/global.scss +10 -0
  106. package/templates/react/ts/scss/rtk/src/utils/utils.ts +59 -0
  107. package/templates/react/ts/scss/rtk/tsconfig.app.json +28 -0
  108. package/templates/react/ts/scss/rtk/tsconfig.json +12 -0
  109. package/templates/react/ts/scss/rtk/tsconfig.node.json +26 -0
  110. package/templates/react/ts/scss/rtk/vite.config.ts +7 -0
@@ -0,0 +1,73 @@
1
+ import { useState } from "react";
2
+ import { Link, useNavigate } from "react-router-dom";
3
+ import VerifyOtpModal from "../component/auth/VerifyOtpModal";
4
+ import "./Signup.scss";
5
+
6
+ const Signup = () => {
7
+ const navigate = useNavigate();
8
+ const [showOtp, setShowOtp] = useState(false);
9
+
10
+ const [form, setForm] = useState({
11
+ email: "",
12
+ password: "",
13
+ });
14
+
15
+ const handleSignup = async () => {
16
+ // const res = await apiCallPost(
17
+ // "/auth/signup",
18
+ // form,
19
+ // {},
20
+ // true
21
+ // );
22
+
23
+ // if (res?.success) {
24
+ // setRefId(res?.data?.refId || "");
25
+ setShowOtp(true);
26
+ // }
27
+ };
28
+
29
+ const handleOtpSuccess = () => {
30
+ navigate("/login");
31
+ };
32
+
33
+ return (
34
+ <div className="signup-container">
35
+ <div className="auth-card">
36
+ <h2 className="auth-title">Signup</h2>
37
+
38
+ <input
39
+ className="auth-input"
40
+ placeholder="Email"
41
+ value={form.email}
42
+ onChange={(e) => setForm({ ...form, email: e.target.value })}
43
+ />
44
+
45
+ <input
46
+ type="password"
47
+ className="auth-input password-input"
48
+ placeholder="Password"
49
+ value={form.password}
50
+ onChange={(e) => setForm({ ...form, password: e.target.value })}
51
+ />
52
+
53
+ <button onClick={handleSignup} className="auth-button">
54
+ Create Account
55
+ </button>
56
+ <span className="auth-footer">
57
+ Already have an account?{" "}
58
+ <Link to="/login" className="auth-link">
59
+ Login
60
+ </Link>
61
+ </span>
62
+ </div>
63
+
64
+ <VerifyOtpModal
65
+ isOpen={showOtp}
66
+ onClose={() => setShowOtp(false)}
67
+ onVerifySuccess={handleOtpSuccess}
68
+ />
69
+ </div>
70
+ );
71
+ };
72
+
73
+ export default Signup;
@@ -0,0 +1,66 @@
1
+ .signup-container {
2
+ min-height: 100vh;
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ background-color: #f3f4f6;
7
+
8
+ .auth-card {
9
+ width: 24rem; // w-96
10
+ padding: 1.5rem; // p-6
11
+ background-color: #ffffff;
12
+ border-radius: 0.375rem; // rounded
13
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); // shadow
14
+
15
+ .auth-title {
16
+ font-size: 1.25rem; // text-xl
17
+ font-weight: 700; // font-bold
18
+ margin-bottom: 1rem; // mb-4
19
+ }
20
+
21
+ .auth-input {
22
+ width: 100%;
23
+ padding: 0.5rem; // p-2
24
+ margin-bottom: 0.5rem; // mb-2
25
+ border: 1px solid #d1d5db; // border
26
+ border-radius: 0.25rem; // rounded
27
+
28
+ &.password-input {
29
+ margin-bottom: 1rem; // mb-4
30
+ }
31
+ }
32
+
33
+ .auth-button {
34
+ width: 100%;
35
+ background-color: #059669; // green-600
36
+ color: #ffffff;
37
+ padding: 0.5rem 0;
38
+ border-radius: 0.25rem;
39
+ border: none;
40
+ cursor: pointer;
41
+ font-weight: 600;
42
+
43
+ &:hover {
44
+ background-color: #047857;
45
+ }
46
+ }
47
+
48
+ .auth-footer {
49
+ display: block;
50
+ text-align: center;
51
+ margin-top: 0.5rem; // mt-2
52
+ font-size: 0.875rem; // text-sm
53
+ color: #4b5563; // text-gray-600
54
+
55
+ .auth-link {
56
+ color: #2563eb; // text-blue-600
57
+ text-decoration: none;
58
+ cursor: pointer;
59
+
60
+ &:hover {
61
+ text-decoration: underline;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,19 @@
1
+ import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
2
+ import Login from "../pages/Login";
3
+ import Signup from "../pages/Signup";
4
+ import Dashboard from "../pages/Dashboard";
5
+
6
+ const AppRouter = () => {
7
+ return (
8
+ <BrowserRouter>
9
+ <Routes>
10
+ <Route path="/" element={<Navigate to="/login" />} />
11
+ <Route path="/login" element={<Login />} />
12
+ <Route path="/signup" element={<Signup />} />
13
+ <Route path="/dashboard" element={<Dashboard />} />
14
+ </Routes>
15
+ </BrowserRouter>
16
+ );
17
+ };
18
+
19
+ export default AppRouter;
@@ -0,0 +1,10 @@
1
+ import { configureStore } from "@reduxjs/toolkit";
2
+ import { api } from "./services/api";
3
+
4
+ export const store = configureStore({
5
+ reducer: {
6
+ [api.reducerPath]: api.reducer,
7
+ },
8
+ middleware: (getDefaultMiddleware) =>
9
+ getDefaultMiddleware().concat(api.middleware),
10
+ });
@@ -0,0 +1,34 @@
1
+ import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
2
+
3
+ export const api = createApi({
4
+ reducerPath: "api",
5
+ baseQuery: fetchBaseQuery({
6
+ baseUrl: import.meta.env.VITE_API_HOST,
7
+ }),
8
+ endpoints: (builder) => ({
9
+ login: builder.mutation({
10
+ query: (body) => ({
11
+ url: "/auth/login",
12
+ method: "POST",
13
+ body,
14
+ }),
15
+ }),
16
+ signup: builder.mutation({
17
+ query: (body) => ({
18
+ url: "/auth/signup",
19
+ method: "POST",
20
+ body,
21
+ }),
22
+ }),
23
+ verifyOtp: builder.mutation({
24
+ query: (body) => ({
25
+ url: "/auth/verify-otp",
26
+ method: "POST",
27
+ body,
28
+ }),
29
+ }),
30
+ }),
31
+ });
32
+
33
+ export const { useLoginMutation, useSignupMutation, useVerifyOtpMutation } =
34
+ api;
@@ -0,0 +1,10 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ body {
6
+ margin: 0;
7
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
8
+ background: #f4f6f8;
9
+ color: #222;
10
+ }
@@ -0,0 +1,59 @@
1
+ import * as CryptoJS from "crypto-js";
2
+ import ENVIRONMENT from "../contants/constants";
3
+
4
+ /**
5
+ * Function to get prime numbers in range (start, end)
6
+ */
7
+ function getPrimeNumbersInRange(start, end) {
8
+ const isPrime = (num) => {
9
+ for (let i = 2, s = Math.sqrt(num); i <= s; i++) {
10
+ if (num % i === 0) return false;
11
+ }
12
+ return num > 1;
13
+ };
14
+
15
+ const primes = [];
16
+ for (let i = start; i <= end; i++) {
17
+ if (isPrime(i)) primes.push(i);
18
+ }
19
+ return primes;
20
+ }
21
+
22
+ export function getKey(value) {
23
+ const key = ENVIRONMENT.STRING || "asdfasdfasd";
24
+
25
+ // Function to get prime numbers in range (1, value)
26
+ const primeNumbers = getPrimeNumbersInRange(1, value);
27
+
28
+ // Get the string according to the prime numbers
29
+ const resultString = primeNumbers
30
+ .map((num) => key[num % key.length])
31
+ .join("");
32
+
33
+ return resultString;
34
+ }
35
+
36
+ const key = getKey(50);
37
+
38
+ const encryptData = (data) => {
39
+ if (data) {
40
+ const stringData = JSON.stringify(data);
41
+ const encrypted = CryptoJS.AES.encrypt(stringData, key).toString();
42
+ return encrypted;
43
+ }
44
+ };
45
+
46
+ const decryptData = (data) => {
47
+ if (data) {
48
+ const decrypted = CryptoJS.AES.decrypt(data, key);
49
+ const stringData = decrypted.toString(CryptoJS.enc.Utf8);
50
+ try {
51
+ return JSON.parse(stringData);
52
+ } catch (e) {
53
+ console.error("Failed to parse decrypted data", e);
54
+ return null;
55
+ }
56
+ }
57
+ };
58
+
59
+ export { encryptData, decryptData };
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "types": ["vite/client"],
9
+ "skipLibCheck": true,
10
+
11
+ /* Bundler mode */
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "moduleDetection": "force",
16
+ "noEmit": true,
17
+ "jsx": "react-jsx",
18
+
19
+ /* Linting */
20
+ "strict": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "erasableSyntaxOnly": true,
24
+ "noFallthroughCasesInSwitch": true,
25
+ "noUncheckedSideEffectImports": true
26
+ },
27
+ "include": ["src"]
28
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ })
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
@@ -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
+ ])
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>react-ts-tailwind-axios</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>