initalization project
This commit is contained in:
commit
455fcd1240
330
.gitignore
vendored
Normal file
330
.gitignore
vendored
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
# ---> Python
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# UV
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
#uv.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||||
|
.pdm.toml
|
||||||
|
.pdm-python
|
||||||
|
.pdm-build/
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
api/.env
|
||||||
|
api/.venv
|
||||||
|
api/env/
|
||||||
|
api/venv/
|
||||||
|
api/ENV/
|
||||||
|
api/env.bak/
|
||||||
|
api/venv.bak/
|
||||||
|
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
||||||
|
|
||||||
|
# Ruff stuff:
|
||||||
|
.ruff_cache/
|
||||||
|
|
||||||
|
# PyPI configuration file
|
||||||
|
.pypirc
|
||||||
|
|
||||||
|
# ---> Node
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# vitepress build output
|
||||||
|
**/.vitepress/dist
|
||||||
|
|
||||||
|
# vitepress cache directory
|
||||||
|
**/.vitepress/cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
|
|
||||||
|
# Custom ignore
|
||||||
|
.DS_Store
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
.dockerignore
|
||||||
|
.vscode
|
||||||
|
my_project_env
|
||||||
|
.cursorignore
|
||||||
9
.gitlab-ci.yml
Normal file
9
.gitlab-ci.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
include:
|
||||||
|
- project: 'cicd/ci'
|
||||||
|
file: 'fastapi-app.yml'
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: 'clone'
|
||||||
|
APP_VERSION: '1.0.0'
|
||||||
|
APP_PORT: 8501
|
||||||
|
APP_SHARED: 1
|
||||||
|
BASE_IMAGE: 'fastapi-template:1.3.0'
|
||||||
BIN
api/requirements.txt
Normal file
BIN
api/requirements.txt
Normal file
Binary file not shown.
11
api/run_server.py
Normal file
11
api/run_server.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import uvicorn
|
||||||
|
from src import app, get_settings
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
settings = get_settings()
|
||||||
|
uvicorn.run(
|
||||||
|
app,
|
||||||
|
host=settings.server.HOST,
|
||||||
|
port=settings.server.PORT,
|
||||||
|
lifespan="on"
|
||||||
|
)
|
||||||
7
api/src/__init__.py
Normal file
7
api/src/__init__.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from .app import app
|
||||||
|
from .conf import get_settings
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"app",
|
||||||
|
"get_settings"
|
||||||
|
]
|
||||||
50
api/src/app.py
Normal file
50
api/src/app.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
from .conf import get_settings
|
||||||
|
from .routes import api_route
|
||||||
|
|
||||||
|
settings = get_settings()
|
||||||
|
|
||||||
|
VERSION = "1.0.0"
|
||||||
|
UP_TIME = datetime.now(timezone.utc)
|
||||||
|
|
||||||
|
app = FastAPI(
|
||||||
|
title="Fast API",
|
||||||
|
version=VERSION,
|
||||||
|
root_path=settings.ROOT_PATH,
|
||||||
|
)
|
||||||
|
|
||||||
|
@app.get(
|
||||||
|
"/healthcheck",
|
||||||
|
status_code=200
|
||||||
|
)
|
||||||
|
async def healthcheck():
|
||||||
|
return {
|
||||||
|
"uptime": UP_TIME,
|
||||||
|
"version": VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
app.add_middleware(ProxyHeadersMiddleware, trusted_hosts=["*"])
|
||||||
|
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["*"],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
#Создание каталога для web приложения
|
||||||
|
os.makedirs(os.path.join('web'), exist_ok=True)
|
||||||
|
|
||||||
|
#Подключаем все ендпоинты и роуты до маунта статических файлов
|
||||||
|
app.include_router(api_route)
|
||||||
|
|
||||||
|
#Подключение собранного web приложения
|
||||||
|
app.mount("/", StaticFiles(directory="web", html=True), name="web")
|
||||||
5
api/src/conf/__init__.py
Normal file
5
api/src/conf/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from .settings import get_settings
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"get_settings"
|
||||||
|
]
|
||||||
9
api/src/conf/models.py
Normal file
9
api/src/conf/models.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class ServerSettings(BaseModel):
|
||||||
|
"""
|
||||||
|
Настройки сервера uvicorn
|
||||||
|
"""
|
||||||
|
HOST: str = '0.0.0.0'
|
||||||
|
PORT: int = 8000
|
||||||
33
api/src/conf/settings.py
Normal file
33
api/src/conf/settings.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from fastapi.logger import logger
|
||||||
|
from pydantic_settings import BaseSettings
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
from .models import ServerSettings
|
||||||
|
from functools import lru_cache
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
""" Настройки приложения """
|
||||||
|
ROOT_PATH: str = '/'
|
||||||
|
|
||||||
|
server: ServerSettings = ServerSettings()
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
extra = 'ignore'
|
||||||
|
env_file = ".env"
|
||||||
|
env_nested_delimiter = '__'
|
||||||
|
nested_model_default_partial_update = False
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
|
def get_settings() -> Settings:
|
||||||
|
"""
|
||||||
|
Получение настроек приложения
|
||||||
|
:return: Настройки приложения
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
_ = load_dotenv()
|
||||||
|
except Exception as err:
|
||||||
|
logger.error("Error load settings", exc_info=err)
|
||||||
|
return Settings()
|
||||||
5
api/src/routes/__init__.py
Normal file
5
api/src/routes/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from .api import api_route
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"api_route"
|
||||||
|
]
|
||||||
5
api/src/routes/api/__init__.py
Normal file
5
api/src/routes/api/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from .route import route as api_route
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"api_route"
|
||||||
|
]
|
||||||
17
api/src/routes/api/route.py
Normal file
17
api/src/routes/api/route.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from fastapi import APIRouter
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
from .schemas import ApiResponse
|
||||||
|
|
||||||
|
route = APIRouter(prefix="/api",tags=['Base'])
|
||||||
|
|
||||||
|
|
||||||
|
@route.get(
|
||||||
|
"",
|
||||||
|
response_model=ApiResponse
|
||||||
|
)
|
||||||
|
async def get_data():
|
||||||
|
return ApiResponse(
|
||||||
|
date_with_time=datetime.now(timezone.utc),
|
||||||
|
text="Fast API приложение"
|
||||||
|
)
|
||||||
7
api/src/routes/api/schemas.py
Normal file
7
api/src/routes/api/schemas.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from pydantic import BaseModel
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
class ApiResponse(BaseModel):
|
||||||
|
date_with_time: datetime
|
||||||
|
text: str
|
||||||
8
raisa_config.yml
Normal file
8
raisa_config.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Конфигурация ресурсов приложения
|
||||||
|
# Доступные профили: Малый (0.25CPU/1GB), Средний (0.5CPU/2GB), Большой (1CPU/4GB), custom
|
||||||
|
# CPU Cores указывается, только с шагом 0.25
|
||||||
|
# RAM GB указывается, только с шагом 1
|
||||||
|
profile:
|
||||||
|
# Последние данные по наименованию профиля: Малый
|
||||||
|
cpu: 0.25 # значение Cores
|
||||||
|
ram: 1.0 # значение GB
|
||||||
1
roles.json
Normal file
1
roles.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
2
setup/.npmrc
Normal file
2
setup/.npmrc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
registry=http://nexus.dev.raisa.go.rshbank.ru/repository/npm/
|
||||||
|
strict-ssl=false
|
||||||
8
setup/pip.conf
Normal file
8
setup/pip.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[global]
|
||||||
|
disable-pip-version-check = True
|
||||||
|
trusted-host = nexus.dev.raisa.go.rshbank.ru
|
||||||
|
index = http://nexus.dev.raisa.go.rshbank.ru/repository/pypi/pypi
|
||||||
|
index-url = http://nexus.dev.raisa.go.rshbank.ru/repository/pypi/simple
|
||||||
|
|
||||||
|
[easy_install]
|
||||||
|
index-url = http://nexus.dev.raisa.go.rshbank.ru/repository/pypi/simple
|
||||||
23
setup/setup.sh
Normal file
23
setup/setup.sh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "setup project to development"
|
||||||
|
|
||||||
|
echo "create virtual environment to api"
|
||||||
|
|
||||||
|
python -m venv ./../api/.venv
|
||||||
|
cp ./pip.conf ./../api/.venv/pip.conf
|
||||||
|
source ./../api/.venv/bin/activate
|
||||||
|
pip install -r ./../api/requirements.txt
|
||||||
|
|
||||||
|
echo "complete setup development api"
|
||||||
|
|
||||||
|
echo "setup web application"
|
||||||
|
|
||||||
|
cp ./.npmrc ./../web/.npmrc
|
||||||
|
cd ./../web
|
||||||
|
|
||||||
|
npm i
|
||||||
|
|
||||||
|
echo "complete setup web application"
|
||||||
|
echo "To start api, cd to api directory, and use venv, start run_server.py"
|
||||||
|
echo "To start api, cd to web directory, and use command npm run start!"
|
||||||
|
echo "Happy Hacking! :)"
|
||||||
1
users.json
Normal file
1
users.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
91
web/biome.json
Normal file
91
web/biome.json
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||||
|
"vcs": {
|
||||||
|
"enabled": true,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": true
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"ignoreUnknown": true,
|
||||||
|
"ignore": ["node_modules"]
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"lineWidth": 140,
|
||||||
|
"formatWithErrors": true
|
||||||
|
},
|
||||||
|
"organizeImports": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"ignore": ["*.json"],
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true,
|
||||||
|
"a11y": {
|
||||||
|
"useButtonType": "off",
|
||||||
|
"noSvgWithoutTitle": "off"
|
||||||
|
},
|
||||||
|
"complexity": {
|
||||||
|
"noForEach": "off",
|
||||||
|
"noUselessTypeConstraint": "warn"
|
||||||
|
},
|
||||||
|
"correctness": {
|
||||||
|
"noUnusedVariables": "error",
|
||||||
|
"noUnusedImports": "error",
|
||||||
|
"useExhaustiveDependencies": "info"
|
||||||
|
},
|
||||||
|
"nursery": {
|
||||||
|
"noCommonJs": "error",
|
||||||
|
"noDuplicateElseIf": "error",
|
||||||
|
"noDuplicateProperties": "error",
|
||||||
|
"noNestedTernary": "error",
|
||||||
|
"useAtIndex": "error",
|
||||||
|
"useCollapsedIf": "error",
|
||||||
|
"useConsistentCurlyBraces": "error"
|
||||||
|
},
|
||||||
|
"performance": {
|
||||||
|
"noDelete": "off",
|
||||||
|
"noAccumulatingSpread": "off"
|
||||||
|
},
|
||||||
|
"style": {
|
||||||
|
"useDefaultSwitchClause": "error",
|
||||||
|
"useForOf": "error",
|
||||||
|
"useFragmentSyntax": "error",
|
||||||
|
"useConsistentArrayType": "error",
|
||||||
|
"useShorthandAssign": "error"
|
||||||
|
},
|
||||||
|
"suspicious": {
|
||||||
|
"noConsole": "warn",
|
||||||
|
"noEmptyBlockStatements": "error",
|
||||||
|
"noEvolvingTypes": "error",
|
||||||
|
"noExplicitAny": "warn",
|
||||||
|
"noSkippedTests": "warn",
|
||||||
|
"useAwait": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"javascript": {
|
||||||
|
"formatter": {
|
||||||
|
"quoteStyle": "single",
|
||||||
|
"jsxQuoteStyle": "single",
|
||||||
|
"bracketSameLine": true
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"json": {
|
||||||
|
"parser": {
|
||||||
|
"allowComments": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"css": {
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"parser": {
|
||||||
|
"cssModules": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
web/package.json
Normal file
27
web/package.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rsbuild build",
|
||||||
|
"start": "rsbuild dev --open",
|
||||||
|
"preview": "rsbuild preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"raisa-ui": "^1.0.0",
|
||||||
|
"react": "^18.3.1",
|
||||||
|
"react-dom": "^18.3.1",
|
||||||
|
"react-daisyui": "^5.0.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "1.9.4",
|
||||||
|
"@rsbuild/core": "^1.2.4",
|
||||||
|
"@rsbuild/plugin-react": "^1.1.0",
|
||||||
|
"@types/react": "^18.3.1",
|
||||||
|
"@types/react-dom": "^18.3.1",
|
||||||
|
"typescript": "^5.7.3",
|
||||||
|
"daisyui": "^4.12.10",
|
||||||
|
"tailwindcss": "^3.4.13"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
web/postcss.config.cjs
Normal file
5
web/postcss.config.cjs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
}
|
||||||
|
}
|
||||||
0
web/public/.gitkeep
Normal file
0
web/public/.gitkeep
Normal file
13
web/public/index.html
Normal file
13
web/public/index.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru-RU">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<title>Пример React-приложения</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
28
web/rsbuild.config.ts
Normal file
28
web/rsbuild.config.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { defineConfig, loadEnv } from '@rsbuild/core';
|
||||||
|
import { pluginReact } from '@rsbuild/plugin-react';
|
||||||
|
|
||||||
|
const { publicVars, rawPublicVars } = loadEnv({prefixes: ['REACT_APP_']});
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
base: (rawPublicVars['REACT_APP_ROOT_PATH'] !== undefined) ? rawPublicVars['REACT_APP_ROOT_PATH'] : '/'
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: {
|
||||||
|
js: '[name]_script.[contenthash:8].js',
|
||||||
|
css: '[name]_style.[contenthash:8].css',
|
||||||
|
},
|
||||||
|
assetPrefix: (rawPublicVars['REACT_APP_ROOT_PATH'] !== undefined) ? rawPublicVars['REACT_APP_ROOT_PATH'] : './'
|
||||||
|
},
|
||||||
|
html: {
|
||||||
|
template: './public/index.html',
|
||||||
|
},
|
||||||
|
source: {
|
||||||
|
include: [{ not: /[\\/]core-js[\\/]/ }],
|
||||||
|
define: {
|
||||||
|
...publicVars,
|
||||||
|
'process.env': JSON.stringify(rawPublicVars),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [pluginReact()],
|
||||||
|
});
|
||||||
40
web/src/App.tsx
Normal file
40
web/src/App.tsx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Config } from './conf/config';
|
||||||
|
import { Card } from 'react-daisyui';
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
|
const [apiResponse, setApiResponse] = useState<{
|
||||||
|
date_with_time: string,
|
||||||
|
text: string
|
||||||
|
}|null>(null);
|
||||||
|
|
||||||
|
// Загрузка данных с сервера
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
fetch(`${Config.API_URL}/api`, {
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
method: 'GET'
|
||||||
|
})
|
||||||
|
.then(async (response) => {
|
||||||
|
setApiResponse(await response.json())
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log('Ошибка при получении данных с api:', error);
|
||||||
|
alert("Ошибка при получении данных с api");
|
||||||
|
})
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='flex items-center justify-center absolute inset-0'>
|
||||||
|
<Card className="flex flex-col gap-2 border-[2px] items-center justify-center border-primary rounded-md p-6" style={{ width: '50vw', height: '200px' }}>
|
||||||
|
<h1>Шаблон приложения Fast API</h1>
|
||||||
|
<p>Время: {(apiResponse?.date_with_time) ? new Date(apiResponse?.date_with_time).toISOString() : "Нет данных по времени"}, Текст: {apiResponse?.text}</p>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
||||||
6
web/src/conf/config.ts
Normal file
6
web/src/conf/config.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
//@ts-ignore
|
||||||
|
const environment = process.env;
|
||||||
|
|
||||||
|
export class Config {
|
||||||
|
static API_URL: string = environment.REACT_APP_API_URL ?? environment.REACT_APP_ROOT_PATH ?? '';
|
||||||
|
}
|
||||||
1
web/src/env.d.ts
vendored
Normal file
1
web/src/env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference types="@rsbuild/core/types" />
|
||||||
17
web/src/index.css
Normal file
17
web/src/index.css
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||||
|
sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||||
|
monospace;
|
||||||
|
}
|
||||||
14
web/src/index.tsx
Normal file
14
web/src/index.tsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import './index.css';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
const rootEl = document.getElementById('root');
|
||||||
|
if (rootEl) {
|
||||||
|
const root = ReactDOM.createRoot(rootEl);
|
||||||
|
root.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>,
|
||||||
|
);
|
||||||
|
}
|
||||||
43
web/tailwind.config.js
Normal file
43
web/tailwind.config.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: [
|
||||||
|
"./src/**/*.{html,js,jsx,ts,tsx}",
|
||||||
|
"node_modules/daisyui/dist/**/*.js",
|
||||||
|
"node_modules/react-daisyui/dist/**/*.js",
|
||||||
|
"node_modules/raisa-ui/dist/**/*.js"
|
||||||
|
],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [require('daisyui')],
|
||||||
|
daisyui: {
|
||||||
|
themes: [
|
||||||
|
{
|
||||||
|
rshb: {
|
||||||
|
...require('daisyui/src/theming/themes')['light'],
|
||||||
|
|
||||||
|
"primary": "#171A1C",
|
||||||
|
"primary-content": "#fcfcfd",
|
||||||
|
"secondary": "#ECEDEF",
|
||||||
|
"secondary-content": "#687178",
|
||||||
|
"accent": "#8ecaff",
|
||||||
|
"accent-content": "#fcfcfd",
|
||||||
|
"neutral": "#ecedef",
|
||||||
|
"neutral-content": "#171A1C",
|
||||||
|
"base-100": "#FCFCFD",
|
||||||
|
"base-200": "#F6F7F8",
|
||||||
|
"base-300": "#ECEDEF",
|
||||||
|
"base-content": "#171A1C",
|
||||||
|
"info": "#0894FF",
|
||||||
|
"info-content": "#E3E5E8",
|
||||||
|
"success": "#39B33D",
|
||||||
|
"success-content": "#E3E5E8",
|
||||||
|
"warning": "#E6B200",
|
||||||
|
"warning-content": "#fcfcfd",
|
||||||
|
"error": "#FF371A",
|
||||||
|
"error-content": "#fcfcfd",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
23
web/tsconfig.json
Normal file
23
web/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["DOM", "ES2020"],
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"target": "ES2020",
|
||||||
|
"noEmit": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
|
||||||
|
/* modules */
|
||||||
|
"module": "ESNext",
|
||||||
|
"isolatedModules": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
|
||||||
|
/* type checking */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user