Refactor routing and documentation for SPA deployment
- Updated the application to serve the SPA from the root path instead of /map/, enhancing accessibility. - Modified redirect logic to ensure backward compatibility with old /map/* URLs. - Adjusted documentation across multiple files to reflect the new routing structure and API endpoints. - Improved handling of OAuth redirects and session management in the backend. - Updated frontend configuration to align with the new base URL settings.
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
|
||||
## Обзор
|
||||
|
||||
hnh-map — сервер автомаппера для HnH: Go-бэкенд с хранилищем bbolt, сессиями и Nuxt 3 SPA по пути `/map/`. Данные гридов и тайлов хранятся в каталоге `grids/` и в БД.
|
||||
hnh-map — сервер автомаппера для HnH: Go-бэкенд с хранилищем bbolt, сессиями и Nuxt 3 SPA по корню `/`. API, SSE и тайлы — по `/map/api/`, `/map/updates`, `/map/grids/`. Данные гридов и тайлов хранятся в каталоге `grids/` и в БД.
|
||||
|
||||
```
|
||||
┌─────────────┐ HTTP/SSE ┌──────────────────────────────────────┐
|
||||
│ Браузер │ ◄────────────────► │ Go-сервер (cmd/hnh-map) │
|
||||
│ (Nuxt SPA │ /map/, /map/api │ • bbolt (users, sessions, grids, │
|
||||
│ по /map/) │ /map/updates │ markers, tiles, maps, config) │
|
||||
│ │ /map/grids/ │ • Статика фронта (frontend/) │
|
||||
└─────────────┘ │ • internal/app — вся логика │
|
||||
└──────────────────────────────────────┘
|
||||
│ (Nuxt SPA │ /, /login, │ • bbolt (users, sessions, grids, │
|
||||
│ по /) │ /map/api, │ markers, tiles, maps, config) │
|
||||
│ │ /map/updates, │ • Статика фронта (frontend/) │
|
||||
│ │ /map/grids/ │ • internal/app — вся логика │
|
||||
└─────────────┘ └──────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Структура бэкенда
|
||||
@@ -19,10 +19,10 @@ hnh-map — сервер автомаппера для HnH: Go-бэкенд с
|
||||
- **cmd/hnh-map/main.go** — единственная точка входа (`package main`): парсинг флагов (`-grids`, `-port`) и переменных окружения (`HNHMAP_PORT`), открытие bbolt, запуск миграций, создание `App`, регистрация маршрутов, запуск HTTP-сервера. Пути к `frontend/` и `public/` задаются из рабочей директории при старте.
|
||||
|
||||
- **internal/app/** — пакет `app` с типом `App` и всей логикой:
|
||||
- **app.go** — структура `App`, общие типы (`Character`, `Session`, `Coord`, `Position`, `Marker`, `User`, `MapInfo`, `GridData` и т.д.), регистрация маршрутов (`RegisterRoutes`), `serveMapFrontend`, `CleanChars`.
|
||||
- **app.go** — структура `App`, общие типы (`Character`, `Session`, `Coord`, `Position`, `Marker`, `User`, `MapInfo`, `GridData` и т.д.), регистрация маршрутов (`RegisterRoutes`), `serveSPARoot`, `CleanChars`.
|
||||
- **auth.go** — сессии и авторизация: `getSession`, `deleteSession`, `saveSession`, `getUser`, `getPage`, `createSession`, `setupRequired`, `requireAdmin`.
|
||||
- **api.go** — HTTP API: авторизация (login, me, logout, setup), кабинет (tokens, password), админ (users, settings, maps, wipe, rebuildZooms, export, merge), роутер `/map/api/...`.
|
||||
- **handlers_redirects.go** — редиректы: `/` → `/map/profile` или `/map/setup`, `/login` → `/map/login`, `/logout` → `/map/login`, `/admin` → `/map/admin`.
|
||||
- **handlers_redirects.go** — редирект `/logout` → `/login` (после удаления сессии).
|
||||
- **client.go** — роутер клиента маппера (`/client/{token}/...`), `locate`.
|
||||
- **client_grid.go** — `gridUpdate`, `gridUpload`, `updateZoomLevel`.
|
||||
- **client_positions.go** — `updatePositions`.
|
||||
|
||||
Reference in New Issue
Block a user