chore: remove unused dependencies and files client & server
This commit is contained in:
parent
ecca216c0b
commit
55beac4477
6 changed files with 31 additions and 492 deletions
|
@ -17,14 +17,11 @@
|
||||||
"@emotion/react": "^11",
|
"@emotion/react": "^11",
|
||||||
"@emotion/styled": "^11",
|
"@emotion/styled": "^11",
|
||||||
"@fontsource/open-sans": "^4.5.8",
|
"@fontsource/open-sans": "^4.5.8",
|
||||||
"axios": "^0.26.1",
|
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"final-form": "^4.20.6",
|
"final-form": "^4.20.6",
|
||||||
"framer-motion": "^6",
|
"framer-motion": "^6",
|
||||||
"graphql": "^15.8.0",
|
"graphql": "^15.8.0",
|
||||||
"graphql-tag": "^2.12.6",
|
"graphql-tag": "^2.12.6",
|
||||||
"immer": "^9.0.12",
|
|
||||||
"js-cookie": "^3.0.1",
|
|
||||||
"next": "12.1.6",
|
"next": "12.1.6",
|
||||||
"react": "18.1.0",
|
"react": "18.1.0",
|
||||||
"react-dom": "18.1.0",
|
"react-dom": "18.1.0",
|
||||||
|
@ -36,7 +33,6 @@
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
"remark-mdx": "^2.1.1",
|
"remark-mdx": "^2.1.1",
|
||||||
"swr": "^1.3.0",
|
"swr": "^1.3.0",
|
||||||
"systeminformation": "^5.11.9",
|
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"validator": "^13.7.0",
|
"validator": "^13.7.0",
|
||||||
"zustand": "^3.7.2"
|
"zustand": "^3.7.2"
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
import axios, { Method } from 'axios';
|
|
||||||
import { useSystemStore } from '../state/systemStore';
|
|
||||||
|
|
||||||
interface IFetchParams {
|
|
||||||
endpoint: string;
|
|
||||||
method?: Method;
|
|
||||||
params?: JSON;
|
|
||||||
data?: Record<string, unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const api = async <T = unknown>(fetchParams: IFetchParams): Promise<T> => {
|
|
||||||
const { endpoint, method = 'GET', params, data } = fetchParams;
|
|
||||||
|
|
||||||
const { getState } = useSystemStore;
|
|
||||||
const BASE_URL = getState().baseUrl;
|
|
||||||
|
|
||||||
const response = await axios.request<T & { error?: string }>({
|
|
||||||
method,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
url: `${BASE_URL}${endpoint}`,
|
|
||||||
withCredentials: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data.error) {
|
|
||||||
throw new Error(response.data.error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.data) return response.data;
|
|
||||||
|
|
||||||
throw new Error(`Network request error. status : ${response.status}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default { fetch: api };
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { BareFetcher } from 'swr';
|
|
||||||
import axios from 'axios';
|
|
||||||
import { useSystemStore } from '../state/systemStore';
|
|
||||||
|
|
||||||
const fetcher: BareFetcher<any> = (url: string) => {
|
|
||||||
const { baseUrl } = useSystemStore.getState();
|
|
||||||
|
|
||||||
return axios.get(url, { baseURL: baseUrl, withCredentials: true }).then((res) => res.data);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default fetcher;
|
|
|
@ -1,74 +0,0 @@
|
||||||
import create from 'zustand';
|
|
||||||
import Cookies from 'js-cookie';
|
|
||||||
import api from '../core/api';
|
|
||||||
import { IUser } from '../core/types';
|
|
||||||
|
|
||||||
type AppsStore = {
|
|
||||||
user: IUser | null;
|
|
||||||
configured: boolean;
|
|
||||||
me: () => Promise<void>;
|
|
||||||
login: (email: string, password: string) => Promise<void>;
|
|
||||||
register: (email: string, password: string) => Promise<void>;
|
|
||||||
logout: () => void;
|
|
||||||
fetchConfigured: () => Promise<void>;
|
|
||||||
loading: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useAuthStore = create<AppsStore>((set) => ({
|
|
||||||
user: null,
|
|
||||||
configured: false,
|
|
||||||
loading: false,
|
|
||||||
me: async () => {
|
|
||||||
try {
|
|
||||||
set({ loading: true });
|
|
||||||
const response = await api.fetch<{ user: IUser | null }>({ endpoint: '/auth/me' });
|
|
||||||
|
|
||||||
set({ user: response.user, loading: false });
|
|
||||||
} catch (error) {
|
|
||||||
set({ loading: false, user: null });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
login: async (email: string, password: string) => {
|
|
||||||
set({ loading: true });
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await api.fetch<{ user: IUser }>({
|
|
||||||
endpoint: '/auth/login',
|
|
||||||
method: 'post',
|
|
||||||
data: { email, password },
|
|
||||||
});
|
|
||||||
set({ user: response.user, loading: false });
|
|
||||||
} catch (e) {
|
|
||||||
set({ loading: false });
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
logout: async () => {
|
|
||||||
Cookies.remove('tipi_token');
|
|
||||||
|
|
||||||
set({ user: null, loading: false });
|
|
||||||
},
|
|
||||||
register: async (email: string, password: string) => {
|
|
||||||
set({ loading: true });
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await api.fetch<{ user: IUser }>({
|
|
||||||
endpoint: '/auth/register',
|
|
||||||
method: 'post',
|
|
||||||
data: { email, password },
|
|
||||||
});
|
|
||||||
set({ user: response.user, loading: false });
|
|
||||||
} catch (e) {
|
|
||||||
set({ loading: false });
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fetchConfigured: async () => {
|
|
||||||
try {
|
|
||||||
const response = await api.fetch<{ configured: boolean }>({ endpoint: '/auth/configured' });
|
|
||||||
set({ configured: response.configured });
|
|
||||||
} catch (e) {
|
|
||||||
set({ configured: false });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}));
|
|
|
@ -30,8 +30,6 @@
|
||||||
"argon2": "^0.29.1",
|
"argon2": "^0.29.1",
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
"class-validator": "^0.13.2",
|
"class-validator": "^0.13.2",
|
||||||
"compression": "^1.7.4",
|
|
||||||
"cookie-parser": "^1.4.6",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"express": "^4.17.3",
|
"express": "^4.17.3",
|
||||||
|
@ -41,18 +39,13 @@
|
||||||
"graphql-type-json": "^0.3.2",
|
"graphql-type-json": "^0.3.2",
|
||||||
"http": "0.0.1-security",
|
"http": "0.0.1-security",
|
||||||
"internal-ip": "^6.0.0",
|
"internal-ip": "^6.0.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
|
||||||
"mock-fs": "^5.1.2",
|
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
"node-cron": "^3.0.1",
|
"node-cron": "^3.0.1",
|
||||||
"node-port-scanner": "^3.0.1",
|
"node-port-scanner": "^3.0.1",
|
||||||
"p-iteration": "^1.1.8",
|
|
||||||
"pg": "^8.7.3",
|
"pg": "^8.7.3",
|
||||||
"public-ip": "^5.0.0",
|
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"semver": "^7.3.7",
|
"semver": "^7.3.7",
|
||||||
"session-file-store": "^1.5.0",
|
"session-file-store": "^1.5.0",
|
||||||
"systeminformation": "^5.11.9",
|
|
||||||
"tcp-port-used": "^1.0.2",
|
"tcp-port-used": "^1.0.2",
|
||||||
"type-graphql": "^1.1.1",
|
"type-graphql": "^1.1.1",
|
||||||
"typeorm": "^0.3.6",
|
"typeorm": "^0.3.6",
|
||||||
|
@ -64,15 +57,11 @@
|
||||||
"@faker-js/faker": "^7.3.0",
|
"@faker-js/faker": "^7.3.0",
|
||||||
"@swc/cli": "^0.1.57",
|
"@swc/cli": "^0.1.57",
|
||||||
"@swc/core": "^1.2.210",
|
"@swc/core": "^1.2.210",
|
||||||
"@types/compression": "^1.7.2",
|
|
||||||
"@types/cookie-parser": "^1.4.3",
|
|
||||||
"@types/cors": "^2.8.12",
|
"@types/cors": "^2.8.12",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
"@types/express-session": "^1.17.4",
|
"@types/express-session": "^1.17.4",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/jest": "^27.5.0",
|
"@types/jest": "^27.5.0",
|
||||||
"@types/jsonwebtoken": "^8.5.8",
|
|
||||||
"@types/mock-fs": "^4.13.1",
|
|
||||||
"@types/node": "17.0.31",
|
"@types/node": "17.0.31",
|
||||||
"@types/node-cron": "^3.0.2",
|
"@types/node-cron": "^3.0.2",
|
||||||
"@types/pg": "^8.6.5",
|
"@types/pg": "^8.6.5",
|
||||||
|
|
389
pnpm-lock.yaml
389
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue