create-fe-boilerplate 0.3.0 → 0.3.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.
package/bin/index.js
CHANGED
|
@@ -39,7 +39,8 @@ async function run() {
|
|
|
39
39
|
type: "list",
|
|
40
40
|
name: "api",
|
|
41
41
|
message: "Choose API layer:",
|
|
42
|
-
choices:
|
|
42
|
+
choices: (answers) =>
|
|
43
|
+
answers.framework === "next" ? ["axios"] : ["axios", "rtk"],
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
type: "input",
|
|
@@ -49,6 +50,9 @@ async function run() {
|
|
|
49
50
|
},
|
|
50
51
|
]);
|
|
51
52
|
|
|
53
|
+
const apiChoices =
|
|
54
|
+
answers.framework === "next" ? ["axios"] : ["axios", "rtk"];
|
|
55
|
+
|
|
52
56
|
/* ---------------- VALIDATE PROJECT NAME ---------------- */
|
|
53
57
|
|
|
54
58
|
const validation = validatePkgName(answers.projectName);
|
|
@@ -67,7 +71,7 @@ async function run() {
|
|
|
67
71
|
answers.framework,
|
|
68
72
|
answers.language,
|
|
69
73
|
answers.style,
|
|
70
|
-
answers.api
|
|
74
|
+
apiChoices.includes(answers.api) ? answers.api : "axios"
|
|
71
75
|
);
|
|
72
76
|
|
|
73
77
|
if (!fs.existsSync(templatePath)) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
|
|
3
|
-
const BASE_URL = process.env.NEXT_PUBLIC_API_HOST;
|
|
4
|
-
|
|
5
3
|
export const axiosApi = axios.create({
|
|
6
|
-
baseURL:
|
|
4
|
+
baseURL: process.env.NEXT_PUBLIC_API_HOST,
|
|
5
|
+
headers: {
|
|
6
|
+
"Content-Type": "application/json",
|
|
7
|
+
},
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
axiosApi.interceptors.request.use((config) => {
|
|
@@ -15,3 +16,16 @@ axiosApi.interceptors.request.use((config) => {
|
|
|
15
16
|
}
|
|
16
17
|
return config;
|
|
17
18
|
});
|
|
19
|
+
|
|
20
|
+
axiosApi.interceptors.response.use(
|
|
21
|
+
(response) => response,
|
|
22
|
+
(error) => {
|
|
23
|
+
if (error?.response?.status === 401) {
|
|
24
|
+
if (typeof window !== "undefined") {
|
|
25
|
+
localStorage.removeItem("token");
|
|
26
|
+
window.location.href = "/login";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return Promise.reject(error);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { axiosApi } from "@/api/axios";
|
|
3
4
|
import { useState } from "react";
|
|
4
5
|
|
|
5
6
|
interface VerifyOtpModalProps {
|
|
@@ -20,9 +21,12 @@ export default function VerifyOtpModal({
|
|
|
20
21
|
if (!isOpen) return null;
|
|
21
22
|
|
|
22
23
|
const handleVerify = async () => {
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// const res = await axiosApi.post("/auth/verify-otp", {
|
|
25
|
+
// refId,
|
|
26
|
+
// otp,
|
|
27
|
+
// });
|
|
28
|
+
|
|
29
|
+
onSuccess("dummy Token");
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
return (
|