diff --git a/apps/web/Caddyfile b/apps/web/Caddyfile new file mode 100644 index 0000000..ab41b5b --- /dev/null +++ b/apps/web/Caddyfile @@ -0,0 +1,25 @@ +:80 { + respond /health 200 { + body "OK" + close + } +} + +app.igeo.pro { + 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" + } +} diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile new file mode 100644 index 0000000..e016d0b --- /dev/null +++ b/apps/web/Dockerfile @@ -0,0 +1,10 @@ +FROM git.jt4d.ru/jt4d/caddy:2-alpine + +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 diff --git a/apps/web/eslint.config.mjs b/apps/web/eslint.config.mjs new file mode 100644 index 0000000..2ebf347 --- /dev/null +++ b/apps/web/eslint.config.mjs @@ -0,0 +1,4 @@ +import nx from '@nx/eslint-plugin'; +import baseConfig from '../../eslint.config.mjs'; + +export default [...nx.configs['flat/react'], ...baseConfig]; diff --git a/apps/web/index.html b/apps/web/index.html new file mode 100644 index 0000000..ce55808 --- /dev/null +++ b/apps/web/index.html @@ -0,0 +1,29 @@ + + + + + Web + + + + + + + +
+ + + diff --git a/apps/web/package.json b/apps/web/package.json new file mode 100644 index 0000000..2ecc0a6 --- /dev/null +++ b/apps/web/package.json @@ -0,0 +1,22 @@ +{ + "name": "@geo-platform/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" + } +} diff --git a/apps/web/postcss.config.js b/apps/web/postcss.config.js new file mode 100644 index 0000000..8df2360 --- /dev/null +++ b/apps/web/postcss.config.js @@ -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: {}, + }, +}; diff --git a/apps/web/project.json b/apps/web/project.json new file mode 100644 index 0000000..cdf92e4 --- /dev/null +++ b/apps/web/project.json @@ -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": {} + } + } +} diff --git a/apps/web/public/favicon.ico b/apps/web/public/favicon.ico new file mode 100644 index 0000000..317ebcb Binary files /dev/null and b/apps/web/public/favicon.ico differ diff --git a/apps/web/src/app/app.spec.tsx b/apps/web/src/app/app.spec.tsx new file mode 100644 index 0000000..1e10d59 --- /dev/null +++ b/apps/web/src/app/app.spec.tsx @@ -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( + + + , + ); + expect(baseElement).toBeTruthy(); + }); + + it('should have a greeting as the title', () => { + const { getAllByText } = render( + + + , + ); + expect(getAllByText(new RegExp('Welcome @geo-platform/web', 'gi')).length > 0).toBeTruthy(); + }); +}); diff --git a/apps/web/src/app/app.tsx b/apps/web/src/app/app.tsx new file mode 100644 index 0000000..c973de6 --- /dev/null +++ b/apps/web/src/app/app.tsx @@ -0,0 +1,49 @@ +import NxWelcome from './nx-welcome'; + +import { Route, Routes, Link } from 'react-router-dom'; + +export function App() { + return ( +
+ + + {/* START: routes */} + {/* These routes and navigation have been generated for you */} + {/* Feel free to move and update them to fit your needs */} +
+
+
+
+
    +
  • + Home +
  • +
  • + Page 2 +
  • +
+
+ + + This is the generated root route. Click here for page 2. +
+ } + /> + + Click here to go back to root page. + + } + /> + + {/* END: routes */} + + ); +} + +export default App; diff --git a/apps/web/src/app/nx-welcome.tsx b/apps/web/src/app/nx-welcome.tsx new file mode 100644 index 0000000..2726272 --- /dev/null +++ b/apps/web/src/app/nx-welcome.tsx @@ -0,0 +1,836 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + This is a starter component and can be deleted. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + Delete this file and get started with your project! + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + */ +export function NxWelcome({ title }: { title: string }) { + return ( + <> +