@anmol0493/fullstack-app 1.0.3 → 1.0.4
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 +2 -2
- package/frontend/src/components/Layout.tsx +13 -5
- package/frontend/vite.config.ts +20 -13
- package/package.json +1 -1
- package/scripts/setup.js +1 -1
package/README.md
CHANGED
|
@@ -15,10 +15,10 @@ This is a **full-stack template** designed to help developers quickly bootstrap
|
|
|
15
15
|
## Getting Started
|
|
16
16
|
|
|
17
17
|
### Prerequisites
|
|
18
|
-
- [Node.js](https://nodejs.org/) (
|
|
18
|
+
- [Node.js](https://nodejs.org/) (v20 or higher)
|
|
19
19
|
- [npm](https://www.npmjs.com/)
|
|
20
20
|
|
|
21
21
|
### Installation
|
|
22
22
|
- ```bash
|
|
23
23
|
npx @anmol0493/fullstack-app my-project
|
|
24
|
-
```
|
|
24
|
+
```
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import { useSelector } from "react-redux";
|
|
2
|
-
import { actions, RootState } from "../redux/store";
|
|
3
|
-
import { Button } from "./ui/Button";
|
|
4
1
|
import { LogOut, TriangleAlert } from "lucide-react";
|
|
5
|
-
import { cn } from "../lib/utils";
|
|
6
|
-
import toast from "react-hot-toast";
|
|
7
2
|
import { useState } from "react";
|
|
3
|
+
import toast from "react-hot-toast";
|
|
4
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
import { authApi } from "../redux/api/auth";
|
|
7
|
+
import { actions, RootState } from "../redux/store";
|
|
8
|
+
import { Button } from "./ui/Button";
|
|
8
9
|
import { CommonAlertDialog } from "./ui/CommonAlertDialog";
|
|
9
10
|
|
|
10
11
|
interface LayoutProps {
|
|
11
12
|
children: React.ReactNode;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
const apiArray = [authApi];
|
|
16
|
+
|
|
14
17
|
export const Layout = ({ children }: LayoutProps) => {
|
|
15
18
|
const { currentUser } = useSelector((state: RootState) => state.auth);
|
|
16
19
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
17
20
|
|
|
21
|
+
const dispatch = useDispatch();
|
|
22
|
+
|
|
18
23
|
const handleLogout = () => {
|
|
24
|
+
apiArray.forEach(api => {
|
|
25
|
+
dispatch(api.util.resetApiState());
|
|
26
|
+
});
|
|
19
27
|
actions.auth.clearToken(null);
|
|
20
28
|
toast.success("Logged out successfully");
|
|
21
29
|
};
|
package/frontend/vite.config.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import react from '@vitejs/plugin-react-swc';
|
|
3
1
|
import tailwindcss from '@tailwindcss/vite';
|
|
2
|
+
import react from '@vitejs/plugin-react-swc';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export default defineConfig(({ mode }) => {
|
|
7
|
+
const env = loadEnv(mode, process.cwd(), '');
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
return {
|
|
10
|
+
plugins: [react(), tailwindcss()],
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'@': path.resolve(__dirname, './src')
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
server: {
|
|
17
|
+
proxy: {
|
|
18
|
+
'/api': {
|
|
19
|
+
target: env.VITE_API_URL,
|
|
20
|
+
changeOrigin: true,
|
|
21
|
+
rewrite: (path) => path.replace(/^\/api/, '')
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
|
-
}
|
|
25
|
+
};
|
|
19
26
|
});
|
package/package.json
CHANGED
package/scripts/setup.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import enquirer from 'enquirer'; // Install enquirer: npm install enquirer
|
|
6
6
|
const { prompt } = enquirer;
|
|
7
|
-
|
|
7
|
+
import { execa } from 'execa'; // Install execa: npm install execa
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
9
9
|
import { dirname } from 'path';
|
|
10
10
|
|