Compare commits
13 Commits
VORKOUT-6-
...
VORKOUT-15
Author | SHA1 | Date | |
---|---|---|---|
92ff1d3d0a | |||
5ed8ca9251 | |||
8ac329e76e | |||
c68b512902 | |||
70aaaeabf1 | |||
92203351ff | |||
ee92428ec3 | |||
c87581c9e2 | |||
79cb434ebd | |||
5def1a9bb1 | |||
d55a99aafd | |||
599bf22bda | |||
e114f963ab |
6
Makefile
6
Makefile
@@ -17,7 +17,7 @@ start-api:
|
|||||||
|
|
||||||
start-client:
|
start-client:
|
||||||
cd client && \
|
cd client && \
|
||||||
npm start
|
npm run dev
|
||||||
|
|
||||||
migrate:
|
migrate:
|
||||||
cd api && \
|
cd api && \
|
||||||
@@ -42,6 +42,10 @@ venv-api:
|
|||||||
poetry env activate \
|
poetry env activate \
|
||||||
poetry install
|
poetry install
|
||||||
|
|
||||||
|
venv-client:
|
||||||
|
cd client && \
|
||||||
|
npm install
|
||||||
|
|
||||||
install:
|
install:
|
||||||
make migrate head && \
|
make migrate head && \
|
||||||
cd api && \
|
cd api && \
|
||||||
|
50
README.md
50
README.md
@@ -1 +1,49 @@
|
|||||||
Vorkout/connect
|
# Vorkout/connect
|
||||||
|
|
||||||
|
### Makefile cheat sheet
|
||||||
|
|
||||||
|
```Makefile
|
||||||
|
Dev:
|
||||||
|
venv-api create python virtual environment
|
||||||
|
venv-client install node modules
|
||||||
|
install Migrate database and initialize project
|
||||||
|
|
||||||
|
Application Api:
|
||||||
|
start-api Run api server
|
||||||
|
|
||||||
|
Application Client:
|
||||||
|
start-client Run client server
|
||||||
|
|
||||||
|
Prod:
|
||||||
|
...
|
||||||
|
|
||||||
|
Code:
|
||||||
|
check-api Check api code with ruff
|
||||||
|
format-api Reformat api code with ruff
|
||||||
|
|
||||||
|
Help:
|
||||||
|
...
|
||||||
|
|
||||||
|
Testing:
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Запуск в режиме разработки
|
||||||
|
|
||||||
|
Для запуска в режиме разработки нужно
|
||||||
|
|
||||||
|
1. Устрановить среду для clint и api
|
||||||
|
2. Запустить в докере или локально необходимые сервисы (базуб брокер и redis) `make services`
|
||||||
|
3. Для миграции и создания первого пользователя необходимо запустить `make install`
|
||||||
|
3. Запустить api `make start-api`
|
||||||
|
4. Запустить client `make start-client`
|
||||||
|
|
||||||
|
### Миграции алембик
|
||||||
|
|
||||||
|
1. Стоит внимательно учитывать, адрес какой базы стоит в настройках alembic - локальной или продакшн. Посмотреть это можно в файле [env.py](connect/api/api/db/alembic/env.py). Конфиг для локальной базы
|
||||||
|
```python
|
||||||
|
config.set_main_option(
|
||||||
|
"sqlalchemy.url",
|
||||||
|
f"mysql+pymysql://root:hackme@localhost:3306/connect_test",
|
||||||
|
)
|
||||||
|
```
|
||||||
|
@@ -18,8 +18,7 @@ class DbCredentialsSchema(BaseModel):
|
|||||||
class DefaultSettings(BaseSettings):
|
class DefaultSettings(BaseSettings):
|
||||||
ENV: str = environ.get("ENV", "local")
|
ENV: str = environ.get("ENV", "local")
|
||||||
PATH_PREFIX: str = environ.get("PATH_PREFIX", "/api/v1")
|
PATH_PREFIX: str = environ.get("PATH_PREFIX", "/api/v1")
|
||||||
# APP_HOST: str = environ.get("APP_HOST", "http://127.0.0.1")
|
APP_HOST: str = environ.get("APP_HOST", "http://127.0.0.1")
|
||||||
APP_HOST: str = environ.get("APP_HOST", "http://localhost")
|
|
||||||
APP_PORT: int = int(environ.get("APP_PORT", 8000))
|
APP_PORT: int = int(environ.get("APP_PORT", 8000))
|
||||||
APP_ID: uuid.UUID = environ.get("APP_ID", uuid.uuid4())
|
APP_ID: uuid.UUID = environ.get("APP_ID", uuid.uuid4())
|
||||||
LOGS_STORAGE_PATH: str = environ.get("LOGS_STORAGE_PATH", "storage/logs")
|
LOGS_STORAGE_PATH: str = environ.get("LOGS_STORAGE_PATH", "storage/logs")
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
import jwt
|
|
||||||
from fastapi import (
|
from fastapi import (
|
||||||
APIRouter,
|
APIRouter,
|
||||||
Depends,
|
Depends,
|
||||||
HTTPException,
|
HTTPException,
|
||||||
Request,
|
|
||||||
Response,
|
Response,
|
||||||
status,
|
status,
|
||||||
|
Request,
|
||||||
)
|
)
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from fastapi_jwt_auth import AuthJWT
|
from fastapi_jwt_auth import AuthJWT
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ from api.services.auth import authenticate_user
|
|||||||
|
|
||||||
from api.db.logic.auth import add_new_refresh_token, upgrade_old_refresh_token
|
from api.db.logic.auth import add_new_refresh_token, upgrade_old_refresh_token
|
||||||
|
|
||||||
from api.schemas.endpoints.auth import Auth, Access
|
from api.schemas.endpoints.auth import Auth, Tokens
|
||||||
|
|
||||||
api_router = APIRouter(
|
api_router = APIRouter(
|
||||||
prefix="/auth",
|
prefix="/auth",
|
||||||
@@ -30,21 +30,11 @@ api_router = APIRouter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_login_from_jwt(token: str):
|
|
||||||
payload = jwt.decode(
|
|
||||||
token,
|
|
||||||
get_settings().SECRET_KEY,
|
|
||||||
algorithms=[get_settings().ALGORITHM],
|
|
||||||
)
|
|
||||||
return payload.get("sub")
|
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseModel):
|
class Settings(BaseModel):
|
||||||
authjwt_secret_key: str = get_settings().SECRET_KEY
|
authjwt_secret_key: str = get_settings().SECRET_KEY
|
||||||
# Configure application to store and get JWT from cookies
|
# Configure application to store and get JWT from cookies
|
||||||
authjwt_token_location: set = {"headers", "cookies"}
|
authjwt_token_location: set = {"headers"}
|
||||||
authjwt_cookie_domain: str = get_settings().DOMAIN
|
authjwt_cookie_domain: str = get_settings().DOMAIN
|
||||||
authjwt_refresh_cookie_name: str = "refresh_token_cookie"
|
|
||||||
|
|
||||||
# Only allow JWT cookies to be sent over https
|
# Only allow JWT cookies to be sent over https
|
||||||
authjwt_cookie_secure: bool = get_settings().ENV == "prod"
|
authjwt_cookie_secure: bool = get_settings().ENV == "prod"
|
||||||
@@ -58,7 +48,7 @@ def get_config():
|
|||||||
return Settings()
|
return Settings()
|
||||||
|
|
||||||
|
|
||||||
@api_router.post("", response_model=Access)
|
@api_router.post("", response_model=Tokens)
|
||||||
async def login_for_access_token(
|
async def login_for_access_token(
|
||||||
user: Auth,
|
user: Auth,
|
||||||
response: Response,
|
response: Response,
|
||||||
@@ -78,9 +68,7 @@ async def login_for_access_token(
|
|||||||
# headers={"WWW-Authenticate": "Bearer"},
|
# headers={"WWW-Authenticate": "Bearer"},
|
||||||
)
|
)
|
||||||
|
|
||||||
# access_token_expires = timedelta(minutes=get_settings().ACCESS_TOKEN_EXPIRE_MINUTES)
|
access_token_expires = timedelta(minutes=get_settings().ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||||
access_token_expires = timedelta(seconds=5)
|
|
||||||
|
|
||||||
refresh_token_expires = timedelta(days=get_settings().REFRESH_TOKEN_EXPIRE_DAYS)
|
refresh_token_expires = timedelta(days=get_settings().REFRESH_TOKEN_EXPIRE_DAYS)
|
||||||
|
|
||||||
logger.debug(f"refresh_token_expires {refresh_token_expires}")
|
logger.debug(f"refresh_token_expires {refresh_token_expires}")
|
||||||
@@ -92,26 +80,27 @@ async def login_for_access_token(
|
|||||||
|
|
||||||
await add_new_refresh_token(connection, refresh_token, refresh_token_expires_time, user)
|
await add_new_refresh_token(connection, refresh_token, refresh_token_expires_time, user)
|
||||||
|
|
||||||
Authorize.set_refresh_cookies(refresh_token)
|
return Tokens(access_token=access_token, refresh_token=refresh_token)
|
||||||
|
|
||||||
return Access(access_token=access_token)
|
|
||||||
|
|
||||||
|
|
||||||
@api_router.post("/refresh", response_model=Access)
|
@api_router.post("/refresh", response_model=Tokens)
|
||||||
async def refresh(
|
async def refresh(
|
||||||
request: Request,
|
request: Request,
|
||||||
connection: AsyncConnection = Depends(get_connection_dep),
|
connection: AsyncConnection = Depends(get_connection_dep),
|
||||||
Authorize: AuthJWT = Depends(),
|
Authorize: AuthJWT = Depends(),
|
||||||
):
|
) -> Tokens:
|
||||||
refresh_token = request.cookies.get("refresh_token_cookie")
|
try:
|
||||||
|
Authorize.jwt_refresh_token_required()
|
||||||
|
current_user = Authorize.get_jwt_subject()
|
||||||
|
except Exception:
|
||||||
|
refresh_token = request.headers.get("Authorization").split(" ")[1]
|
||||||
|
await upgrade_old_refresh_token(connection, refresh_token)
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
detail="Invalid refresh token",
|
||||||
|
)
|
||||||
|
|
||||||
if not refresh_token:
|
access_token_expires = timedelta(minutes=get_settings().ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||||
raise HTTPException(status_code=401, detail="Refresh token is missing")
|
|
||||||
Authorize.jwt_refresh_token_required(refresh_token)
|
|
||||||
current_user = Authorize.get_jwt_subject()
|
|
||||||
# try:
|
|
||||||
# access_token_expires = timedelta(minutes=get_settings().ACCESS_TOKEN_EXPIRE_MINUTES)
|
|
||||||
access_token_expires = timedelta(seconds=5)
|
|
||||||
new_access_token = Authorize.create_access_token(subject=current_user, expires_time=access_token_expires)
|
new_access_token = Authorize.create_access_token(subject=current_user, expires_time=access_token_expires)
|
||||||
|
|
||||||
return Access(access_token=new_access_token)
|
return Tokens(access_token=new_access_token)
|
||||||
|
@@ -8,9 +8,6 @@ class Auth(Base):
|
|||||||
password: str
|
password: str
|
||||||
|
|
||||||
|
|
||||||
class Refresh(Base):
|
class Tokens(Base):
|
||||||
refresh_token: str
|
|
||||||
|
|
||||||
|
|
||||||
class Access(Base):
|
|
||||||
access_token: str
|
access_token: str
|
||||||
|
refresh_token: str | None = None
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
from fastapi_jwt_auth import AuthJWT
|
||||||
from starlette.middleware.base import BaseHTTPMiddleware
|
from starlette.middleware.base import BaseHTTPMiddleware
|
||||||
from fastapi import (
|
from fastapi import (
|
||||||
Request,
|
Request,
|
||||||
@@ -11,9 +12,6 @@ import re
|
|||||||
from re import escape
|
from re import escape
|
||||||
|
|
||||||
|
|
||||||
from fastapi_jwt_auth import AuthJWT
|
|
||||||
|
|
||||||
|
|
||||||
class MiddlewareAccessTokenValidadtion(BaseHTTPMiddleware):
|
class MiddlewareAccessTokenValidadtion(BaseHTTPMiddleware):
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
super().__init__(app)
|
super().__init__(app)
|
||||||
@@ -32,10 +30,8 @@ class MiddlewareAccessTokenValidadtion(BaseHTTPMiddleware):
|
|||||||
status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
|
status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
|
||||||
content={"detail": "Method not allowed"},
|
content={"detail": "Method not allowed"},
|
||||||
)
|
)
|
||||||
|
|
||||||
if any(pattern.match(request.url.path) for pattern in self.excluded_routes):
|
if any(pattern.match(request.url.path) for pattern in self.excluded_routes):
|
||||||
return await call_next(request)
|
return await call_next(request)
|
||||||
|
|
||||||
auth_header = request.headers.get("Authorization")
|
auth_header = request.headers.get("Authorization")
|
||||||
if not auth_header:
|
if not auth_header:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
@@ -43,7 +39,6 @@ class MiddlewareAccessTokenValidadtion(BaseHTTPMiddleware):
|
|||||||
content={"detail": "Missing authorization header."},
|
content={"detail": "Missing authorization header."},
|
||||||
headers={"WWW-Authenticate": "Bearer"},
|
headers={"WWW-Authenticate": "Bearer"},
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
token = auth_header.split(" ")[1]
|
token = auth_header.split(" ")[1]
|
||||||
Authorize = AuthJWT(request)
|
Authorize = AuthJWT(request)
|
||||||
@@ -55,5 +50,4 @@ class MiddlewareAccessTokenValidadtion(BaseHTTPMiddleware):
|
|||||||
content={"detail": "The access token is invalid or expired."},
|
content={"detail": "The access token is invalid or expired."},
|
||||||
headers={"WWW-Authenticate": "Bearer"},
|
headers={"WWW-Authenticate": "Bearer"},
|
||||||
)
|
)
|
||||||
|
|
||||||
return await call_next(request)
|
return await call_next(request)
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "api"
|
name = "api"
|
||||||
version = "0.0.3"
|
version = "0.0.4"
|
||||||
description = ""
|
description = ""
|
||||||
authors = [
|
authors = [{ name = "Vladislav", email = "vlad.dev@heado.ru" }]
|
||||||
{name = "Vladislav",email = "vlad.dev@heado.ru"}
|
|
||||||
]
|
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11,<4.0"
|
requires-python = ">=3.11,<4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
REACT_APP_WEBSOCKET_PROTOCOL=ws
|
VITE_APP_WEBSOCKET_PROTOCOL=ws
|
||||||
REACT_APP_HTTP_PROTOCOL=http
|
VITE_APP_HTTP_PROTOCOL=http
|
||||||
REACT_APP_API_URL=localhost:8000
|
VITE_APP_API_URL=localhost:8000
|
||||||
REACT_APP_URL=localhost:3000
|
VITE_APP_URL=localhost:3000
|
||||||
BROWSER=none
|
|
||||||
|
17
client/index.html
Normal file
17
client/index.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<meta name="description" content="Web site created using Vite" />
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||||
|
<link rel="manifest" href="/manifest.json" />
|
||||||
|
<title>VORKOUT</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
17480
client/package-lock.json
generated
17480
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^5.6.1",
|
"@ant-design/icons": "^5.6.1",
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
"@testing-library/react": "^16.2.0",
|
"@testing-library/react": "^16.2.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^27.5.2",
|
||||||
"@types/node": "^16.18.126",
|
|
||||||
"@types/react": "^19.0.11",
|
"@types/react": "^19.0.11",
|
||||||
"@types/react-dom": "^19.0.4",
|
"@types/react-dom": "^19.0.4",
|
||||||
"antd": "^5.24.7",
|
"antd": "^5.24.7",
|
||||||
@@ -21,16 +20,13 @@
|
|||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-i18next": "^15.5.1",
|
"react-i18next": "^15.5.1",
|
||||||
"react-router-dom": "^7.5.0",
|
"react-router-dom": "^7.5.0",
|
||||||
"react-scripts": "5.0.1",
|
|
||||||
"typescript": "^4.9.5",
|
|
||||||
"web-vitals": "^2.1.4",
|
"web-vitals": "^2.1.4",
|
||||||
"zustand": "^5.0.5"
|
"zustand": "^5.0.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"dev": "vite",
|
||||||
"build": "react-scripts build",
|
"build": "vite build",
|
||||||
"test": "react-scripts test",
|
"preview": "vite preview"
|
||||||
"eject": "react-scripts eject"
|
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
@@ -49,5 +45,13 @@
|
|||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||||
|
"@types/node": "^20.19.1",
|
||||||
|
"@vitejs/plugin-react": "^4.5.2",
|
||||||
|
"typescript": "^5.8.3",
|
||||||
|
"vite": "^6.3.5",
|
||||||
|
"vite-plugin-node-polyfills": "^0.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
client/public/favicon.ico
Normal file
BIN
client/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@@ -1,43 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<meta name="theme-color" content="#000000" />
|
|
||||||
<meta
|
|
||||||
name="description"
|
|
||||||
content="Web site created using create-react-app"
|
|
||||||
/>
|
|
||||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
||||||
<!--
|
|
||||||
manifest.json provides metadata used when your web app is installed on a
|
|
||||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
||||||
-->
|
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
||||||
<!--
|
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
|
||||||
Only files inside the `public` folder can be referenced from the HTML.
|
|
||||||
|
|
||||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
||||||
work correctly both with client-side routing and a non-root public URL.
|
|
||||||
Learn how to configure a non-root public URL by running `npm run build`.
|
|
||||||
-->
|
|
||||||
<title>VORKOUT</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
||||||
<div id="root"></div>
|
|
||||||
<!--
|
|
||||||
This HTML file is a template.
|
|
||||||
If you open it directly in the browser, you will see an empty page.
|
|
||||||
|
|
||||||
You can add webfonts, meta tags, or analytics to this file.
|
|
||||||
The build step will place the bundled scripts into the <body> tag.
|
|
||||||
|
|
||||||
To begin the development, run `npm start` or `yarn start`.
|
|
||||||
To create a production bundle, use `npm run build` or `yarn build`.
|
|
||||||
-->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@@ -1,10 +1,21 @@
|
|||||||
import React from 'react';
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
import { Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import MainLayout from './pages/MainLayout';
|
import { useSetUserSelector } from './store/userStore';
|
||||||
import ProtectedRoute from './pages/ProtectedRoute';
|
|
||||||
import LoginPage from './pages/LoginPage';
|
import LoginPage from './pages/LoginPage';
|
||||||
|
import ProtectedRoute from './pages/ProtectedRoute';
|
||||||
|
import MainLayout from './pages/MainLayout';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
const setUser = useSetUserSelector();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const storedUser = localStorage.getItem('user');
|
||||||
|
if (storedUser) {
|
||||||
|
setUser(JSON.parse(storedUser));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Routes>
|
<Routes>
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Access, Auth } from '../types/auth';
|
// import { Auth, Tokens } from '../types/auth';
|
||||||
import { User } from '../types/user';
|
|
||||||
import { AuthService } from '../services/auth';
|
|
||||||
import axiosRetry from 'axios-retry';
|
import axiosRetry from 'axios-retry';
|
||||||
|
import { Auth, Tokens } from '@/types/auth';
|
||||||
|
import { useAuthStore } from '@/store/authStore';
|
||||||
|
import { AuthService } from '@/services/authService';
|
||||||
|
import { User } from '@/types/user';
|
||||||
|
|
||||||
const baseURL = `${process.env.REACT_APP_HTTP_PROTOCOL}://${process.env.REACT_APP_API_URL}/api/v1`;
|
const baseURL = `${import.meta.env.VITE_APP_HTTP_PROTOCOL}://${
|
||||||
|
import.meta.env.VITE_APP_API_URL
|
||||||
|
}/api/v1`;
|
||||||
|
|
||||||
const base = axios.create({
|
const base = axios.create({
|
||||||
baseURL,
|
baseURL,
|
||||||
@@ -15,35 +19,40 @@ const base = axios.create({
|
|||||||
});
|
});
|
||||||
|
|
||||||
base.interceptors.request.use((config) => {
|
base.interceptors.request.use((config) => {
|
||||||
const token = localStorage.getItem('accessToken');
|
if (config.url === '/auth/refresh') {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
const token = useAuthStore.getState().accessToken;
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers.Authorization = `Bearer ${token}`;
|
config.headers.Authorization = `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
// axiosRetry(base, {
|
axiosRetry(base, {
|
||||||
// retries: 3,
|
retries: 3,
|
||||||
// retryDelay: (retryCount: number) => {
|
retryDelay: (retryCount: number) => {
|
||||||
// console.log(`retry attempt: ${retryCount}`);
|
console.log(`retry attempt: ${retryCount}`);
|
||||||
// return retryCount * 2000;
|
return retryCount * 2000;
|
||||||
// },
|
},
|
||||||
// retryCondition: async (error: any) => {
|
retryCondition: async (error: any) => {
|
||||||
// if (error.code === 'ERR_CANCELED') {
|
if (error.code === 'ERR_CANCELED') {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// return false;
|
return false;
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
|
|
||||||
base.interceptors.response.use(
|
base.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
async function (error) {
|
async function (error) {
|
||||||
|
if (!error.response) {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
const originalRequest = error.response.config;
|
const originalRequest = error.response.config;
|
||||||
console.log('originalRequest._retry', originalRequest);
|
|
||||||
const urlTokens = error?.request?.responseURL.split('/');
|
const urlTokens = error?.request?.responseURL.split('/');
|
||||||
const url = urlTokens[urlTokens.length - 1];
|
const url = urlTokens[urlTokens.length - 1];
|
||||||
console.log('url', url);
|
console.log('url', url);
|
||||||
@@ -55,11 +64,13 @@ base.interceptors.response.use(
|
|||||||
url !== 'logout'
|
url !== 'logout'
|
||||||
) {
|
) {
|
||||||
originalRequest._retry = true;
|
originalRequest._retry = true;
|
||||||
const res = await AuthService.refresh().catch(async () => {
|
try {
|
||||||
|
await AuthService.refresh();
|
||||||
|
return base(originalRequest);
|
||||||
|
} catch (error) {
|
||||||
await AuthService.logout();
|
await AuthService.logout();
|
||||||
});
|
return new Promise(() => {});
|
||||||
console.log('res', res);
|
}
|
||||||
return await base(originalRequest);
|
|
||||||
}
|
}
|
||||||
return await Promise.reject(error);
|
return await Promise.reject(error);
|
||||||
}
|
}
|
||||||
@@ -67,14 +78,22 @@ base.interceptors.response.use(
|
|||||||
|
|
||||||
const api = {
|
const api = {
|
||||||
// auth
|
// auth
|
||||||
async login(auth: Auth): Promise<Access> {
|
async login(auth: Auth): Promise<Tokens> {
|
||||||
console.log(auth);
|
const response = await base.post<Tokens>('/auth', auth);
|
||||||
const response = await base.post<Access>('/auth', auth);
|
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
async refreshToken(): Promise<Access> {
|
async refreshToken(): Promise<Tokens> {
|
||||||
const response = await base.post<Access>('/auth/refresh');
|
const token = localStorage.getItem('refreshToken');
|
||||||
|
const response = await base.post<Tokens>(
|
||||||
|
'/auth/refresh',
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -83,6 +102,13 @@ const api = {
|
|||||||
const response = await base.get<User>('/profile');
|
const response = await base.get<User>('/profile');
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getUsers(page: number, limit: number): Promise<any> {
|
||||||
|
const response = await base.get<User[]>(
|
||||||
|
`/account?page=${page}&limit=${limit}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default api;
|
export default api;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
import './i18n';
|
import '@/config/i18n';
|
||||||
import { ConfigProvider } from 'antd';
|
import { ConfigProvider } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import { theme } from './customTheme';
|
import { theme } from '@/config/customTheme';
|
||||||
|
|
||||||
import en from 'antd/locale/en_US';
|
import en from 'antd/locale/en_US';
|
||||||
import ru from 'antd/locale/ru_RU';
|
import ru from 'antd/locale/ru_RU';
|
||||||
@@ -18,7 +19,7 @@ export default function AppWrapper({ children }: any) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigProvider locale={antdLocales[currentLang]} theme={theme}>
|
<ConfigProvider locale={antdLocales[currentLang]} theme={theme}>
|
||||||
{children}
|
<BrowserRouter>{children}</BrowserRouter>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
12
client/src/env.d.ts
vendored
Normal file
12
client/src/env.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly VITE_APP_WEBSOCKET_PROTOCOL: string;
|
||||||
|
readonly VITE_APP_HTTP_PROTOCOL: string;
|
||||||
|
readonly VITE_APP_API_URL: string;
|
||||||
|
readonly VITE_APP_URL: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
@@ -1,9 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import './index.css';
|
import '@/index.css';
|
||||||
import App from './App';
|
import App from '@/App';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import AppWrapper from '@/config/AppWrapper';
|
||||||
import AppWrapper from './config/AppWrapper';
|
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById('root') as HTMLElement
|
document.getElementById('root') as HTMLElement
|
||||||
@@ -11,8 +10,6 @@ const root = ReactDOM.createRoot(
|
|||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<BrowserRouter>
|
<App />
|
||||||
<App />
|
|
||||||
</BrowserRouter>
|
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
);
|
);
|
@@ -1,8 +1,9 @@
|
|||||||
import Header from '../components/Header';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import ContentDrawer from '../components/ContentDrawer';
|
|
||||||
import UserCreate from '../components/UserCreate';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { User } from '@/types/user';
|
||||||
|
import Header from '@/components/Header';
|
||||||
|
import ContentDrawer from '@/components/ContentDrawer';
|
||||||
|
import UserCreate from '@/components/UserCreate';
|
||||||
|
|
||||||
export default function AccountsPage() {
|
export default function AccountsPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -11,6 +12,8 @@ export default function AccountsPage() {
|
|||||||
const showDrawer = () => setOpen(true);
|
const showDrawer = () => setOpen(true);
|
||||||
const closeDrawer = () => setOpen(false);
|
const closeDrawer = () => setOpen(false);
|
||||||
|
|
||||||
|
const [accounts, setAccounts] = useState<User[]>([]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header
|
<Header
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
import Header from '@/components/Header';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Header from '../components/Header';
|
|
||||||
|
|
||||||
export default function ConfigurationPage() {
|
export default function ConfigurationPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
import Header from '@/components/Header';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Header from '../components/Header';
|
|
||||||
|
|
||||||
export default function EventsListPage() {
|
export default function EventsListPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@@ -5,9 +5,9 @@ import {
|
|||||||
EyeTwoTone,
|
EyeTwoTone,
|
||||||
UserOutlined,
|
UserOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { AuthService } from '../services/auth';
|
|
||||||
import { Auth } from '../types/auth';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { AuthService } from '@/services/authService';
|
||||||
|
import { Auth } from '@/types/auth';
|
||||||
|
|
||||||
const { Text, Link } = Typography;
|
const { Text, Link } = Typography;
|
||||||
|
|
||||||
|
@@ -2,15 +2,13 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Layout } from 'antd';
|
import { Layout } from 'antd';
|
||||||
import Sider from 'antd/es/layout/Sider';
|
import Sider from 'antd/es/layout/Sider';
|
||||||
import SiderMenu from '../components/SiderMenu';
|
|
||||||
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
import SiderMenu from '@/components/SiderMenu';
|
||||||
import ProcessDiagramPage from './ProcessDiagramPage';
|
import ProcessDiagramPage from './ProcessDiagramPage';
|
||||||
import RunningProcessesPage from './RunningProcessesPage';
|
import RunningProcessesPage from './RunningProcessesPage';
|
||||||
import AccountsPage from './AccountsPage';
|
import AccountsPage from './AccountsPage';
|
||||||
import EventsListPage from './EventsListPage';
|
import EventsListPage from './EventsListPage';
|
||||||
import ConfigurationPage from './ConfigurationPage';
|
import ConfigurationPage from './ConfigurationPage';
|
||||||
import { useSetUserSelector } from '../store/user';
|
|
||||||
import { UserService } from '../services/user';
|
|
||||||
|
|
||||||
export default function MainLayout() {
|
export default function MainLayout() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -21,8 +19,6 @@ export default function MainLayout() {
|
|||||||
const [width, setWidth] = useState<number | string>('15%');
|
const [width, setWidth] = useState<number | string>('15%');
|
||||||
const [collapsedWidth, setCollapsedWidth] = useState(50);
|
const [collapsedWidth, setCollapsedWidth] = useState(50);
|
||||||
|
|
||||||
const setUser = useSetUserSelector()
|
|
||||||
|
|
||||||
const calculateWidths = () => {
|
const calculateWidths = () => {
|
||||||
const windowWidth = window.innerWidth;
|
const windowWidth = window.innerWidth;
|
||||||
const expanded = Math.min(Math.max(windowWidth * 0.15, 180), 240);
|
const expanded = Math.min(Math.max(windowWidth * 0.15, 180), 240);
|
||||||
@@ -58,21 +54,6 @@ export default function MainLayout() {
|
|||||||
navigate(key);
|
navigate(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const token = localStorage.getItem('accessToken');
|
|
||||||
if (!token) {
|
|
||||||
navigate('/login');
|
|
||||||
} else {
|
|
||||||
if (localStorage.getItem('user')) {
|
|
||||||
setUser(JSON.parse(localStorage.getItem('user') as string))
|
|
||||||
} else {
|
|
||||||
UserService.getProfile().then((user) => {
|
|
||||||
setUser(user);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout style={{ minHeight: '100vh' }}>
|
<Layout style={{ minHeight: '100vh' }}>
|
||||||
<Sider
|
<Sider
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
import Header from '@/components/Header';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Header from '../components/Header';
|
|
||||||
|
|
||||||
export default function ProcessDiagramPage() {
|
export default function ProcessDiagramPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
// ProtectedRoute.js
|
|
||||||
import { Outlet, useNavigate } from 'react-router-dom';
|
import { Outlet, useNavigate } from 'react-router-dom';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useUserSelector } from '../store/user';
|
import { useUserSelector } from '@/store/userStore';
|
||||||
|
|
||||||
const ProtectedRoute = (): React.JSX.Element => {
|
const ProtectedRoute = (): React.JSX.Element => {
|
||||||
const user = useUserSelector();
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const user = useUserSelector();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user.id === null) {
|
if (!user?.id) {
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
import Header from '@/components/Header';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Header from '../components/Header';
|
|
||||||
|
|
||||||
export default function RunningProcessesPage() {
|
export default function RunningProcessesPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
import api from '../api/api';
|
|
||||||
import { useUserStore } from '../store/user';
|
|
||||||
import { Auth } from '../types/auth';
|
|
||||||
|
|
||||||
export class AuthService {
|
|
||||||
static async login(auth: Auth) {
|
|
||||||
const token = await api.login(auth);
|
|
||||||
console.log(token)
|
|
||||||
localStorage.setItem('accessToken', token.accessToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
static async logout() {
|
|
||||||
useUserStore.getState().removeUser();
|
|
||||||
localStorage.removeItem('userInfo');
|
|
||||||
localStorage.removeItem('accessToken');
|
|
||||||
}
|
|
||||||
|
|
||||||
static async refresh() {
|
|
||||||
const token = await api.refreshToken();
|
|
||||||
localStorage.setItem('accessToken', token.accessToken);
|
|
||||||
}
|
|
||||||
}
|
|
30
client/src/services/authService.ts
Normal file
30
client/src/services/authService.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import api from "@/api/api";
|
||||||
|
import { useAuthStore } from "@/store/authStore";
|
||||||
|
import { Auth } from "@/types/auth";
|
||||||
|
import { UserService } from "./userService";
|
||||||
|
import { useUserStore } from "@/store/userStore";
|
||||||
|
|
||||||
|
export class AuthService {
|
||||||
|
static async login(auth: Auth) {
|
||||||
|
const token = await api.login(auth);
|
||||||
|
useAuthStore.getState().setAccessToken(token.accessToken);
|
||||||
|
localStorage.setItem('refreshToken', token.refreshToken as string);
|
||||||
|
await UserService.getProfile().then((user) => {
|
||||||
|
useUserStore.getState().setUser(user);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static async logout() {
|
||||||
|
console.log('logout');
|
||||||
|
useUserStore.getState().setUser(null);
|
||||||
|
useAuthStore.getState().setAccessToken(null);
|
||||||
|
localStorage.removeItem('userInfo');
|
||||||
|
localStorage.removeItem('refreshToken');
|
||||||
|
}
|
||||||
|
|
||||||
|
static async refresh() {
|
||||||
|
console.log('refresh');
|
||||||
|
const token = await api.refreshToken();
|
||||||
|
useAuthStore.getState().setAccessToken(token.accessToken);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,10 +0,0 @@
|
|||||||
import api from '../api/api';
|
|
||||||
import { User } from '../types/user';
|
|
||||||
|
|
||||||
export class UserService {
|
|
||||||
static async getProfile(): Promise<User> {
|
|
||||||
const user = api.getProfile();
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
16
client/src/services/userService.ts
Normal file
16
client/src/services/userService.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import api from '@/api/api';
|
||||||
|
import { User } from '@/types/user';
|
||||||
|
|
||||||
|
export class UserService {
|
||||||
|
static async getProfile(): Promise<User> {
|
||||||
|
console.log('getProfile');
|
||||||
|
const user = api.getProfile();
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUsers(page: number = 1, limit: number = 10): Promise<any> {
|
||||||
|
const users = api.getUsers(page, limit);
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
}
|
18
client/src/store/authStore.ts
Normal file
18
client/src/store/authStore.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { create } from 'zustand';
|
||||||
|
import { devtools } from 'zustand/middleware';
|
||||||
|
|
||||||
|
type AuthState = {
|
||||||
|
accessToken: string | null;
|
||||||
|
setAccessToken: (token: string | null) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useAuthStore = create<AuthState>()(
|
||||||
|
devtools((set) => ({
|
||||||
|
accessToken: null,
|
||||||
|
setAccessToken: (token) => set({ accessToken: token }),
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
|
export const useAuthSelector = () => {
|
||||||
|
return useAuthStore((state) => state.accessToken);
|
||||||
|
};
|
@@ -1,17 +1,16 @@
|
|||||||
|
import { User } from '@/types/user';
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { devtools, persist } from 'zustand/middleware';
|
import { devtools, persist } from 'zustand/middleware';
|
||||||
import { User } from '../types/user';
|
|
||||||
|
|
||||||
const userInfo = localStorage.getItem('userInfo');
|
const userInfo = localStorage.getItem('userInfo');
|
||||||
|
|
||||||
type UserStoreState = {
|
type UserStoreState = {
|
||||||
user: User;
|
user: User | null;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type UserStoreActions = {
|
type UserStoreActions = {
|
||||||
setUser: (user: User) => void;
|
setUser: (user: User | null) => void;
|
||||||
removeUser: () => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type UserStore = UserStoreState & UserStoreActions;
|
type UserStore = UserStoreState & UserStoreActions;
|
||||||
@@ -22,8 +21,7 @@ export const useUserStore = create<UserStore>()(
|
|||||||
(set, get) => ({
|
(set, get) => ({
|
||||||
user: userInfo != null ? JSON.parse(userInfo) : ({} as User),
|
user: userInfo != null ? JSON.parse(userInfo) : ({} as User),
|
||||||
loading: false,
|
loading: false,
|
||||||
setUser: (user: User) => set({ user }),
|
setUser: (user: User | null) => set({ user }),
|
||||||
removeUser: () => set({ user: {} as User }),
|
|
||||||
}),
|
}),
|
||||||
{ name: 'userInfo' }
|
{ name: 'userInfo' }
|
||||||
)
|
)
|
@@ -1,4 +1,4 @@
|
|||||||
import { components } from './openapi-types';
|
import { components } from './openapi-types';
|
||||||
|
|
||||||
export type Auth = components['schemas']['Auth'];
|
export type Auth = components['schemas']['Auth'];
|
||||||
export type Access = components['schemas']['Access'];
|
export type Tokens = components['schemas']['Tokens'];
|
||||||
|
@@ -120,11 +120,6 @@ export interface paths {
|
|||||||
export type webhooks = Record<string, never>;
|
export type webhooks = Record<string, never>;
|
||||||
export interface components {
|
export interface components {
|
||||||
schemas: {
|
schemas: {
|
||||||
/** Access */
|
|
||||||
Access: {
|
|
||||||
/** Accesstoken */
|
|
||||||
accessToken: string;
|
|
||||||
};
|
|
||||||
/** AccountKeyring */
|
/** AccountKeyring */
|
||||||
AccountKeyring: {
|
AccountKeyring: {
|
||||||
/** Ownerid */
|
/** Ownerid */
|
||||||
@@ -219,6 +214,13 @@ export interface components {
|
|||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
KeyType: "PASSWORD" | "ACCESS_TOKEN" | "REFRESH_TOKEN" | "API_KEY";
|
KeyType: "PASSWORD" | "ACCESS_TOKEN" | "REFRESH_TOKEN" | "API_KEY";
|
||||||
|
/** Tokens */
|
||||||
|
Tokens: {
|
||||||
|
/** Accesstoken */
|
||||||
|
accessToken: string;
|
||||||
|
/** Refreshtoken */
|
||||||
|
refreshToken?: string | null;
|
||||||
|
};
|
||||||
/** User */
|
/** User */
|
||||||
User: {
|
User: {
|
||||||
/** Id */
|
/** Id */
|
||||||
@@ -305,7 +307,7 @@ export interface operations {
|
|||||||
[name: string]: unknown;
|
[name: string]: unknown;
|
||||||
};
|
};
|
||||||
content: {
|
content: {
|
||||||
"application/json": components["schemas"]["Access"];
|
"application/json": components["schemas"]["Tokens"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/** @description Validation Error */
|
/** @description Validation Error */
|
||||||
@@ -334,7 +336,7 @@ export interface operations {
|
|||||||
[name: string]: unknown;
|
[name: string]: unknown;
|
||||||
};
|
};
|
||||||
content: {
|
content: {
|
||||||
"application/json": components["schemas"]["Access"];
|
"application/json": components["schemas"]["Tokens"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
import { components } from "./openapi-types"
|
import { components } from './openapi-types';
|
||||||
|
|
||||||
export type User = components["schemas"]["User"];
|
export type User = components['schemas']['User'];
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"lib": [
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"esnext"
|
|
||||||
],
|
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
@@ -18,9 +14,11 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx"
|
"jsx": "react-jsx",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["src"]
|
||||||
"src"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
23
client/vite.config.ts
Normal file
23
client/vite.config.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import react from '@vitejs/plugin-react';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
port: 3000,
|
||||||
|
open: false,
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
outDir: 'build',
|
||||||
|
},
|
||||||
|
preview: {
|
||||||
|
port: 3000,
|
||||||
|
open: false,
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, './src'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
6
package-lock.json
generated
6
package-lock.json
generated
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "connect",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {}
|
|
||||||
}
|
|
@@ -1 +0,0 @@
|
|||||||
{}
|
|
@@ -32,11 +32,11 @@ startretries=5
|
|||||||
|
|
||||||
[program:client]
|
[program:client]
|
||||||
environment=
|
environment=
|
||||||
REACT_APP_WEBSOCKET_PROTOCOL=ws,
|
VITE_APP_WEBSOCKET_PROTOCOL=ws,
|
||||||
REACT_APP_HTTP_PROTOCOL=http,
|
VITE_APP_HTTP_PROTOCOL=http,
|
||||||
REACT_APP_API_URL=localhost:8000,
|
VITE_APP_API_URL=localhost:8000,
|
||||||
REACT_APP_URL=localhost:3000
|
VITE_APP_URL=localhost:3000
|
||||||
command=bash -c 'cd client; npm run build; serve -s build'
|
command=bash -c 'cd client; npm run build; npm run preview'
|
||||||
numprocs=1
|
numprocs=1
|
||||||
process_name=node-%(process_num)d
|
process_name=node-%(process_num)d
|
||||||
stdout_logfile=client.out.log
|
stdout_logfile=client.out.log
|
||||||
|
Reference in New Issue
Block a user