@anmol0493/fullstack-app 1.0.2 → 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 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/) (v16 or higher)
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
  };
@@ -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
- const apiUrl = import.meta.env.VITE_API_URL;
6
+ export default defineConfig(({ mode }) => {
7
+ const env = loadEnv(mode, process.cwd(), '');
6
8
 
7
- // https://vite.dev/config/
8
- export default defineConfig({
9
- plugins: [react(), tailwindcss()],
10
- server: {
11
- proxy: {
12
- '/api': {
13
- target: apiUrl,
14
- changeOrigin: true,
15
- rewrite: (path) => path.replace(/^\/api/, '')
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anmol0493/fullstack-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A full-stack template with Vite React frontend and Express/NestJS backend options.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/scripts/setup.js CHANGED
File without changes