Initial commit
CI / Сборка (push) Canceled after 0s
CI / Деплой на стейджинг (push) Canceled after 0s
CI / Проверка кода (push) Canceled after 0s
CI / Сборка (pull_request) Successful in 1m33s
Стенд master
CI / Деплой на стейджинг (pull_request) Successful in 8s
CI / Проверка кода (pull_request) Successful in 1m32s

This commit is contained in:
arswarog committed 2026-11-10 17:22:12 +03:00
commit 1420aad1ae
92 files changed
+19114

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
:80 {
respond /health "OK" {
close
}
}
jt4d.ru, http://*.jt4d.jt4d.ru.net {
root * /app
encode gzip
# Обработка API
handle /api/* {
reverse_proxy api:5000
}
# Обработка остального (SPA)
handle {
try_files {path} /index.html
file_server
@static path *.js *.css *.woff *.woff2 *.svg *.png *.jpg *.jpeg *.gif *.ico
header @static Cache-Control "public, max-age=31536000, immutable"
}
}
+16
View File
@@ -0,0 +1,16 @@
:80 {
root * /app
encode gzip
handle /api/* {
reverse_proxy api:5000
}
handle {
try_files {path} /index.html
file_server
@static path *.js *.css *.woff *.woff2 *.svg *.png *.jpg *.jpeg *.gif *.ico
header @static Cache-Control "public, max-age=31536000, immutable"
}
}
+12
View File
@@ -0,0 +1,12 @@
FROM git.jt4d.ru/jt4d/caddy:2-alpine
ARG CADDYFILE=Caddyfile
COPY ./dist /app
EXPOSE 80 443
COPY ${CADDYFILE} /etc/caddy/Caddyfile
HEALTHCHECK --interval=10s --timeout=3s --retries=3 \
CMD curl -f http://localhost:80/health || exit 1
+4
View File
@@ -0,0 +1,4 @@
import nx from '@nx/eslint-plugin';
import baseConfig from '../../eslint.config.mjs';
export default [...nx.configs['flat/react'], ...baseConfig];
+29
View File
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Web</title>
<base href="/" />
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
<link
rel="icon"
type="image/x-icon"
href="/favicon.ico"
/>
<link
rel="stylesheet"
href="/src/styles.css"
/>
</head>
<body>
<div id="root"></div>
<script
type="module"
src="/src/main.tsx"
></script>
</body>
</html>
+22
View File
@@ -0,0 +1,22 @@
{
"name": "@it-smi/web",
"version": "0.0.1",
"private": true,
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^6.30.3"
},
"devDependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.3.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@vitejs/plugin-react": "^4.2.0",
"eslint-plugin-jsx-a11y": "^6.10.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^5.0.0",
"jsdom": "^30.0.1",
"tailwindcss": "^3.4.3"
}
}
+11
View File
@@ -0,0 +1,11 @@
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
export default {
plugins: {
tailwindcss: { config: join(__dirname, 'tailwind.config.js') },
autoprefixer: {},
},
};
+88
View File
@@ -0,0 +1,88 @@
{
"name": "web",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/web/src",
"projectType": "application",
"tags": [],
"targets": {
"clean": {
"executor": "nx:run-commands",
"options": {
"commands": [
"rimraf apps/web/dist"
]
}
},
"build": {
"executor": "@nx/vite:build",
"options": {
"outputPath": "apps/web/dist/",
"base": "/",
"viteConfig": "apps/web/vite.config.ts"
}
},
"typecheck": {
"executor": "nx:run-commands",
"options": {
"command": "tsc --noEmit -p tsconfig.spec.json",
"cwd": "apps/web"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"{projectRoot}/**/*.{ts,tsx}"
],
"eslintConfig": "{projectRoot}/eslint.config.mjs",
"fix": true
}
},
"lint-check": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"{projectRoot}/**/*.{ts,tsx}"
],
"eslintConfig": "{projectRoot}/eslint.config.mjs"
}
},
"format": {
"executor": "nx:run-commands",
"options": {
"parallel": false,
"commands": [
"prettier --write {projectRoot}",
"stylelint --fix \"{projectRoot}/**/*.{scss,css}\""
]
}
},
"format-check": {
"executor": "nx:run-commands",
"options": {
"parallel": false,
"commands": [
"prettier --check {projectRoot}",
"stylelint \"{projectRoot}/**/*.{scss,css}\""
]
}
},
"serve": {
"executor": "@nx/vite:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "web:build",
"port": 5173
},
"configurations": {}
},
"preview": {
"executor": "@nx/vite:preview-server",
"options": {
"buildTarget": "web:build",
"port": 5173
},
"configurations": {}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+24
View File
@@ -0,0 +1,24 @@
import { render } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import App from './app';
describe('App', () => {
it('should render successfully', () => {
const { baseElement } = render(
<BrowserRouter>
<App />
</BrowserRouter>,
);
expect(baseElement).toBeTruthy();
});
it('should have a greeting as the title', () => {
const { getAllByText } = render(
<BrowserRouter>
<App />
</BrowserRouter>,
);
expect(getAllByText(/Hello @it-smi\/web/i).length > 0).toBeTruthy();
});
});
+42
View File
@@ -0,0 +1,42 @@
import { Link, Route, Routes } from 'react-router-dom';
import { HealthPage } from '../pages/HealthPage';
export function App() {
return (
<div>
<h1 className="text-2xl font-bold">Hello @it-smi/web</h1>
<nav role="navigation">
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/page-2">Page 2</Link>
</li>
<li>
<Link to="/health">Health</Link>
</li>
</ul>
</nav>
<Routes>
<Route
path="/"
element={<div>This is the generated root route.</div>}
/>
<Route
path="/health"
element={<HealthPage />}
/>
<Route
path="/page-2"
element={<div>Page 2</div>}
/>
</Routes>
</div>
);
}
export default App;
View File
Whitespace-only changes.
+16
View File
@@ -0,0 +1,16 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import App from './app/app';
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>,
);
+30
View File
@@ -0,0 +1,30 @@
import { render, screen } from '@testing-library/react';
import { HealthPage } from './HealthPage';
describe('HealthPage', () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it('показывает версию API из ответа сервера', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: () => Promise.resolve({ status: 'ok', version: 'v1.2.3' }),
});
vi.stubGlobal('fetch', fetchMock);
render(<HealthPage />);
expect(await screen.findByText('v1.2.3')).toBeTruthy();
expect(fetchMock).toHaveBeenCalledWith('/api/health');
});
it('показывает, что API недоступен, если запрос упал', async () => {
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('network')));
render(<HealthPage />);
expect(await screen.findByText('down')).toBeTruthy();
});
});
+78
View File
@@ -0,0 +1,78 @@
import { useEffect, useState } from 'react';
export function HealthPage() {
const webVersion = import.meta.env.APP_VERSION || 'unknown';
const [apiVersion, setApiVersion] = useState<string | null>(null);
const [apiError, setApiError] = useState(false);
useEffect(() => {
fetch('/api/health')
.then((r) => {
if (!r.ok) throw new Error(String(r.status));
return r.json();
})
.then((d) => setApiVersion(d?.version ?? 'unknown'))
.catch(() => setApiError(true));
}, []);
return (
<div
className="min-h-screen"
style={{ backgroundColor: 'var(--bg-primary)' }}
>
<div className="max-w-lg mx-auto px-4 py-16">
<h1
className="text-2xl font-bold mb-8"
style={{ color: 'var(--text-primary)' }}
>
Health
</h1>
<div
className="rounded-lg border p-6 space-y-4"
style={{
backgroundColor: 'var(--bg-secondary)',
borderColor: 'var(--border-color)',
}}
>
<div className="flex justify-between items-center">
<span
className="text-sm font-medium"
style={{ color: 'var(--text-secondary)' }}
>
Web version
</span>
<span
className="text-sm font-mono"
style={{ color: 'var(--text-primary)' }}
>
{webVersion}
</span>
</div>
<div className="flex justify-between items-center">
<span
className="text-sm font-medium"
style={{ color: 'var(--text-secondary)' }}
>
API version
</span>
{apiError ? (
<span
className="text-sm font-mono"
style={{ color: 'var(--color-error, #ef4444)' }}
>
down
</span>
) : (
<span
className="text-sm font-mono"
style={{ color: 'var(--text-primary)' }}
>
{apiVersion ?? '...'}
</span>
)}
</div>
</div>
</div>
</div>
);
}
+5
View File
@@ -0,0 +1,5 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
/* You can add global styles to this file, and also import other style files */
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+19
View File
@@ -0,0 +1,19 @@
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { createGlobPatternsForDependencies } from '@nx/react/tailwind';
const __dirname = dirname(fileURLToPath(import.meta.url));
/** @type {import('tailwindcss').Config} */
export default {
content: [
join(__dirname, './src/**/*!(*.stories|*.spec).{ts,tsx,html}'),
join(__dirname, './index.html'),
...createGlobPatternsForDependencies(__dirname),
],
theme: {
extend: {},
},
plugins: [],
};
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
+13
View File
@@ -0,0 +1,13 @@
{
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json"
}
+18
View File
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"outDir": "./out-tsc/vitest",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"include": [
"src"
]
}
+48
View File
@@ -0,0 +1,48 @@
/// <reference types='vitest' />
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
export default defineConfig(() => ({
root: import.meta.dirname,
cacheDir: '../../node_modules/.vite/apps/web',
server: {
port: 5173,
host: 'localhost',
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true,
},
},
},
preview: {
port: 5173,
host: 'localhost',
},
plugins: [react()],
envPrefix: ['VITE_', 'APP_'],
// Uncomment this if you are using workers.
// worker: {
// plugins: [],
// },
build: {
outDir: './dist',
emptyOutDir: true,
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
},
test: {
name: '@it-smi/web',
watch: false,
globals: true,
environment: 'jsdom',
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: './test-output/vitest/coverage',
provider: 'v8' as const,
},
},
}));