mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 21:31:46 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2ffea5ba4 | |||
| b0dee4dafb | |||
| beb48af8ed | |||
| e2be3ec191 |
@@ -161,6 +161,7 @@ services:
|
|||||||
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
||||||
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
||||||
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
||||||
|
# - MCP_MAX_SESSION_PER_USER=5 # Max concurrent MCP sessions per user (default: 5)
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
- ./uploads:/app/uploads
|
- ./uploads:/app/uploads
|
||||||
@@ -303,6 +304,7 @@ trek.yourdomain.com {
|
|||||||
| **Other** | | |
|
| **Other** | | |
|
||||||
| `DEMO_MODE` | Enable demo mode (hourly data resets) | `false` |
|
| `DEMO_MODE` | Enable demo mode (hourly data resets) | `false` |
|
||||||
| `MCP_RATE_LIMIT` | Max MCP API requests per user per minute | `60` |
|
| `MCP_RATE_LIMIT` | Max MCP API requests per user per minute | `60` |
|
||||||
|
| `MCP_MAX_SESSION_PER_USER` | Max concurrent MCP sessions per user | `5` |
|
||||||
|
|
||||||
## Optional API Keys
|
## Optional API Keys
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ env:
|
|||||||
# Enable demo mode (hourly data resets).
|
# Enable demo mode (hourly data resets).
|
||||||
# MCP_RATE_LIMIT: "60"
|
# MCP_RATE_LIMIT: "60"
|
||||||
# Max MCP API requests per user per minute. Defaults to 60.
|
# Max MCP API requests per user per minute. Defaults to 60.
|
||||||
|
# MCP_MAX_SESSION_PER_USER: "5"
|
||||||
|
# Max concurrent MCP sessions per user. Defaults to 5.
|
||||||
|
|
||||||
|
|
||||||
# Secret environment variables stored in a Kubernetes Secret.
|
# Secret environment variables stored in a Kubernetes Secret.
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.6",
|
"version": "2.9.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.6",
|
"version": "2.9.8",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-pdf/renderer": "^4.3.2",
|
"@react-pdf/renderer": "^4.3.2",
|
||||||
"axios": "^1.6.7",
|
"axios": "^1.6.7",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-client",
|
"name": "trek-client",
|
||||||
"version": "2.9.6",
|
"version": "2.9.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -480,15 +480,13 @@ export default function AtlasPage(): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match feature by ISO code OR region name
|
// Match feature by ISO code OR region name (native or English)
|
||||||
const isVisitedFeature = (f: any) => {
|
const isVisitedFeature = (f: any) => {
|
||||||
if (visitedRegionCodes.has(f.properties?.iso_3166_2)) return true
|
if (visitedRegionCodes.has(f.properties?.iso_3166_2)) return true
|
||||||
const name = (f.properties?.name || '').toLowerCase()
|
const name = (f.properties?.name || '').toLowerCase()
|
||||||
if (visitedRegionNames.has(name)) return true
|
if (visitedRegionNames.has(name)) return true
|
||||||
// Fuzzy: check if any visited name is contained in feature name or vice versa
|
const nameEn = (f.properties?.name_en || '').toLowerCase()
|
||||||
for (const vn of visitedRegionNames) {
|
if (nameEn && visitedRegionNames.has(nameEn)) return true
|
||||||
if (name.includes(vn) || vn.includes(name)) return true
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,15 +533,16 @@ export default function AtlasPage(): React.ReactElement {
|
|||||||
},
|
},
|
||||||
onEachFeature: (feature, layer) => {
|
onEachFeature: (feature, layer) => {
|
||||||
const regionName = feature?.properties?.name || ''
|
const regionName = feature?.properties?.name || ''
|
||||||
|
const regionNameEn = feature?.properties?.name_en || ''
|
||||||
const countryName = feature?.properties?.admin || ''
|
const countryName = feature?.properties?.admin || ''
|
||||||
const regionCode = feature?.properties?.iso_3166_2 || ''
|
const regionCode = feature?.properties?.iso_3166_2 || ''
|
||||||
const countryA2 = (feature?.properties?.iso_a2 || '').toUpperCase()
|
const countryA2 = (feature?.properties?.iso_a2 || '').toUpperCase()
|
||||||
const visited = isVisitedFeature(feature)
|
const visited = isVisitedFeature(feature)
|
||||||
const count = regionPlaceCounts[regionCode] || regionPlaceCounts[regionName.toLowerCase()] || 0
|
const count = regionPlaceCounts[regionCode] || regionPlaceCounts[regionName.toLowerCase()] || regionPlaceCounts[regionNameEn.toLowerCase()] || 0
|
||||||
layer.on('click', () => {
|
layer.on('click', () => {
|
||||||
if (!countryA2) return
|
if (!countryA2) return
|
||||||
if (visited) {
|
if (visited) {
|
||||||
const regionEntry = visitedRegions[countryA2]?.find(r => r.code === regionCode)
|
const regionEntry = visitedRegions[countryA2]?.find(r => r.code === regionCode || r.name.toLowerCase() === regionNameEn.toLowerCase())
|
||||||
if (regionEntry?.manuallyMarked) {
|
if (regionEntry?.manuallyMarked) {
|
||||||
setConfirmActionRef.current({
|
setConfirmActionRef.current({
|
||||||
type: 'unmark-region',
|
type: 'unmark-region',
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ services:
|
|||||||
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
# - ADMIN_EMAIL=admin@trek.local # Initial admin e-mail — only used on first boot when no users exist
|
||||||
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
# - ADMIN_PASSWORD=changeme # Initial admin password — only used on first boot when no users exist
|
||||||
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
# - MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
||||||
|
# - MCP_MAX_SESSION_PER_USER=5 # Max concurrent MCP sessions per user (default: 5)
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
- ./uploads:/app/uploads
|
- ./uploads:/app/uploads
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ OIDC_SCOPE=openid email profile # Fully overrides the default. Add extra scopes
|
|||||||
DEMO_MODE=false # Demo mode - resets data hourly
|
DEMO_MODE=false # Demo mode - resets data hourly
|
||||||
|
|
||||||
# MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
# MCP_RATE_LIMIT=60 # Max MCP API requests per user per minute (default: 60)
|
||||||
|
# MCP_MAX_SESSION_PER_USER=5 # Max concurrent MCP sessions per user (default: 5)
|
||||||
|
|
||||||
# Initial admin account — only used on first boot when no users exist yet.
|
# Initial admin account — only used on first boot when no users exist yet.
|
||||||
# If both are set the admin account is created with these credentials.
|
# If both are set the admin account is created with these credentials.
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.6",
|
"version": "2.9.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.6",
|
"version": "2.9.8",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.28.0",
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
||||||
"archiver": "^6.0.1",
|
"archiver": "^6.0.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "trek-server",
|
"name": "trek-server",
|
||||||
"version": "2.9.6",
|
"version": "2.9.8",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --import tsx src/index.ts",
|
"start": "node --import tsx src/index.ts",
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ interface McpSession {
|
|||||||
const sessions = new Map<string, McpSession>();
|
const sessions = new Map<string, McpSession>();
|
||||||
|
|
||||||
const SESSION_TTL_MS = 60 * 60 * 1000; // 1 hour
|
const SESSION_TTL_MS = 60 * 60 * 1000; // 1 hour
|
||||||
const MAX_SESSIONS_PER_USER = 5;
|
const sessionParsed = Number.parseInt(process.env.MCP_MAX_SESSION_PER_USER ?? "");
|
||||||
|
const MAX_SESSIONS_PER_USER = Number.isFinite(sessionParsed) && sessionParsed > 0 ? sessionParsed : 5;
|
||||||
const RATE_LIMIT_WINDOW_MS = 60 * 1000; // 1 minute
|
const RATE_LIMIT_WINDOW_MS = 60 * 1000; // 1 minute
|
||||||
const parsed = Number.parseInt(process.env.MCP_RATE_LIMIT ?? "");
|
const parsed = Number.parseInt(process.env.MCP_RATE_LIMIT ?? "");
|
||||||
const RATE_LIMIT_MAX = Number.isFinite(parsed) && parsed > 0 ? parsed : 60; // requests per minute per user
|
const RATE_LIMIT_MAX = Number.isFinite(parsed) && parsed > 0 ? parsed : 60; // requests per minute per user
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ async function reverseGeocodeRegion(lat: number, lng: number): Promise<RegionInf
|
|||||||
if (regionCode && /^[A-Z]{2}-\d+[A-Z]$/i.test(regionCode)) {
|
if (regionCode && /^[A-Z]{2}-\d+[A-Z]$/i.test(regionCode)) {
|
||||||
regionCode = regionCode.replace(/[A-Z]$/i, '');
|
regionCode = regionCode.replace(/[A-Z]$/i, '');
|
||||||
}
|
}
|
||||||
const regionName = data.address?.county || data.address?.state || data.address?.province || data.address?.region || data.address?.city || null;
|
const regionName = data.address?.state || data.address?.province || data.address?.region || data.address?.county || data.address?.city || null;
|
||||||
if (!countryCode || !regionName) { regionCache.set(key, null); return null; }
|
if (!countryCode || !regionName) { regionCache.set(key, null); return null; }
|
||||||
const info: RegionInfo = {
|
const info: RegionInfo = {
|
||||||
country_code: countryCode,
|
country_code: countryCode,
|
||||||
|
|||||||
@@ -202,3 +202,184 @@ describe('Bucket list', () => {
|
|||||||
expect(res.status).toBe(404);
|
expect(res.status).toBe(404);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Mark/unmark region', () => {
|
||||||
|
it('ATLAS-009 — POST /region/:code/mark marks a region as visited', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
expect(res.body.success).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-009 — POST /region/:code/mark without name returns 400', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ country_code: 'DE' });
|
||||||
|
|
||||||
|
expect(res.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-009 — POST /region/:code/mark without country_code returns 400', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen' });
|
||||||
|
|
||||||
|
expect(res.status).toBe(400);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-009 — marking a region also auto-marks the parent country', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
const stats = await request(app)
|
||||||
|
.get('/api/addons/atlas/stats')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
const codes = (stats.body.countries as any[]).map((c: any) => c.code);
|
||||||
|
expect(codes).toContain('DE');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-009 — marking the same region twice is idempotent', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-010 — GET /regions returns marked regions grouped by country', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-BY/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Bayern', country_code: 'DE' });
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.get('/api/addons/atlas/regions')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
expect(res.body).toHaveProperty('regions');
|
||||||
|
const deRegions = res.body.regions['DE'] as any[];
|
||||||
|
expect(deRegions).toBeDefined();
|
||||||
|
const codes = deRegions.map((r: any) => r.code);
|
||||||
|
expect(codes).toContain('DE-NW');
|
||||||
|
expect(codes).toContain('DE-BY');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-011 — DELETE /region/:code/mark unmarks a region', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
const del = await request(app)
|
||||||
|
.delete('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
expect(del.status).toBe(200);
|
||||||
|
expect(del.body.success).toBe(true);
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.get('/api/addons/atlas/regions')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
const deRegions = res.body.regions['DE'] as any[] | undefined;
|
||||||
|
const codes = (deRegions || []).map((r: any) => r.code);
|
||||||
|
expect(codes).not.toContain('DE-NW');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-011 — unmark last region in country also unmarks the parent country', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.delete('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
const stats = await request(app)
|
||||||
|
.get('/api/addons/atlas/stats')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
const codes = (stats.body.countries as any[]).map((c: any) => c.code);
|
||||||
|
expect(codes).not.toContain('DE');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-011 — unmark one region keeps country when another region remains', async () => {
|
||||||
|
const { user } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-BY/mark')
|
||||||
|
.set('Cookie', authCookie(user.id))
|
||||||
|
.send({ name: 'Bayern', country_code: 'DE' });
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.delete('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
const stats = await request(app)
|
||||||
|
.get('/api/addons/atlas/stats')
|
||||||
|
.set('Cookie', authCookie(user.id));
|
||||||
|
|
||||||
|
const codes = (stats.body.countries as any[]).map((c: any) => c.code);
|
||||||
|
expect(codes).toContain('DE');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ATLAS-011 — regions are isolated between users', async () => {
|
||||||
|
const { user: user1 } = createUser(testDb);
|
||||||
|
const { user: user2 } = createUser(testDb);
|
||||||
|
|
||||||
|
await request(app)
|
||||||
|
.post('/api/addons/atlas/region/DE-NW/mark')
|
||||||
|
.set('Cookie', authCookie(user1.id))
|
||||||
|
.send({ name: 'Nordrhein-Westfalen', country_code: 'DE' });
|
||||||
|
|
||||||
|
const res = await request(app)
|
||||||
|
.get('/api/addons/atlas/regions')
|
||||||
|
.set('Cookie', authCookie(user2.id));
|
||||||
|
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
const deRegions = res.body.regions['DE'] as any[] | undefined;
|
||||||
|
expect(deRegions).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -58,4 +58,5 @@
|
|||||||
<!-- Other -->
|
<!-- Other -->
|
||||||
<Config Name="DEMO_MODE" Target="DEMO_MODE" Default="false" Mode="" Description="Enable demo mode (resets all data hourly). Not intended for regular use." Type="Variable" Display="advanced" Required="false" Mask="false">false</Config>
|
<Config Name="DEMO_MODE" Target="DEMO_MODE" Default="false" Mode="" Description="Enable demo mode (resets all data hourly). Not intended for regular use." Type="Variable" Display="advanced" Required="false" Mask="false">false</Config>
|
||||||
<Config Name="MCP_RATE_LIMIT" Target="MCP_RATE_LIMIT" Default="60" Mode="" Description="Max MCP API requests per user per minute." Type="Variable" Display="advanced" Required="false" Mask="false">60</Config>
|
<Config Name="MCP_RATE_LIMIT" Target="MCP_RATE_LIMIT" Default="60" Mode="" Description="Max MCP API requests per user per minute." Type="Variable" Display="advanced" Required="false" Mask="false">60</Config>
|
||||||
|
<Config Name="MCP_MAX_SESSION_PER_USER" Target="MCP_MAX_SESSION_PER_USER" Default="5" Mode="" Description="Max concurrent MCP sessions per user." Type="Variable" Display="advanced" Required="false" Mask="false">5</Config>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user