create-fe-boilerplate 0.2.0 → 0.3.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/bin/index.js +52 -12
- package/package.json +11 -3
- package/templates/next/ts/tailwind/axios/README.md +36 -0
- package/templates/next/ts/tailwind/axios/eslint.config.mjs +18 -0
- package/templates/next/ts/tailwind/axios/next.config.ts +7 -0
- package/templates/next/ts/tailwind/axios/package-lock.json +6626 -0
- package/templates/next/ts/tailwind/axios/package.json +27 -0
- package/templates/next/ts/tailwind/axios/postcss.config.mjs +7 -0
- package/templates/next/ts/tailwind/axios/public/file.svg +1 -0
- package/templates/next/ts/tailwind/axios/public/globe.svg +1 -0
- package/templates/next/ts/tailwind/axios/public/next.svg +1 -0
- package/templates/next/ts/tailwind/axios/public/vercel.svg +1 -0
- package/templates/next/ts/tailwind/axios/public/window.svg +1 -0
- package/templates/next/ts/tailwind/axios/src/api/auth.ts +10 -0
- package/templates/next/ts/tailwind/axios/src/api/axios.ts +17 -0
- package/templates/next/ts/tailwind/axios/src/app/dashboard/page.tsx +32 -0
- package/templates/next/ts/tailwind/axios/src/app/favicon.ico +0 -0
- package/templates/next/ts/tailwind/axios/src/app/globals.css +26 -0
- package/templates/next/ts/tailwind/axios/src/app/layout.tsx +34 -0
- package/templates/next/ts/tailwind/axios/src/app/login/page.tsx +71 -0
- package/templates/next/ts/tailwind/axios/src/app/page.tsx +5 -0
- package/templates/next/ts/tailwind/axios/src/app/signup/page.tsx +56 -0
- package/templates/next/ts/tailwind/axios/src/components/AuthGuard.tsx +35 -0
- package/templates/next/ts/tailwind/axios/src/components/VerifyOtpModal.tsx +58 -0
- package/templates/next/ts/tailwind/axios/tsconfig.json +36 -0
- package/templates/react/js/tailwind/axios/vite.config.js +1 -1
- package/templates/react/js/tailwind/rtk/README.md +73 -0
- package/templates/react/js/tailwind/rtk/eslint.config.js +23 -0
- package/templates/react/js/tailwind/rtk/index.html +13 -0
- package/templates/react/js/tailwind/rtk/package-lock.json +4597 -0
- package/templates/react/js/tailwind/rtk/package.json +37 -0
- package/templates/react/js/tailwind/rtk/postcss.config.js +6 -0
- package/templates/react/js/tailwind/rtk/public/vite.svg +1 -0
- package/templates/react/js/tailwind/rtk/react-ts-tailwind-axios/.env.example +1 -0
- package/templates/react/js/tailwind/rtk/src/App.css +0 -0
- package/templates/react/js/tailwind/rtk/src/App.jsx +14 -0
- package/templates/react/js/tailwind/rtk/src/api/axios.ts +236 -0
- package/templates/react/js/tailwind/rtk/src/component/auth/VerifyOtpModal.jsx +60 -0
- package/templates/react/js/tailwind/rtk/src/component/common/ui/Toast/Toast.js +59 -0
- package/templates/react/js/tailwind/rtk/src/contants/constants.js +45 -0
- package/templates/react/js/tailwind/rtk/src/index.css +4 -0
- package/templates/react/js/tailwind/rtk/src/main.jsx +14 -0
- package/templates/react/js/tailwind/rtk/src/pages/Dashboard.jsx +10 -0
- package/templates/react/js/tailwind/rtk/src/pages/Login.jsx +69 -0
- package/templates/react/js/tailwind/rtk/src/pages/Signup.jsx +75 -0
- package/templates/react/js/tailwind/rtk/src/router/AppRoutes.jsx +19 -0
- package/templates/react/js/tailwind/rtk/src/store/index.js +10 -0
- package/templates/react/js/tailwind/rtk/src/store/services/api.js +34 -0
- package/templates/react/js/tailwind/rtk/src/utils/utils.ts +59 -0
- package/templates/react/js/tailwind/rtk/tailwind.config.js +8 -0
- package/templates/react/js/tailwind/rtk/vite.config.js +7 -0
|
@@ -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,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: number, end: number): number[] {
|
|
8
|
+
const isPrime = (num: number) => {
|
|
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: number): string {
|
|
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: any) => {
|
|
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: any) => {
|
|
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 };
|