import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; import path from 'node:path'; import test from 'node:test'; const root = path.resolve(import.meta.dirname, '..'); const read = relativePath => fs.readFile(path.join(root, relativePath), 'utf8'); test('complete REST API documentation is kept outside the README', async () => { const readme = await read('README.md'); const api = await read('docs/REST-API.md'); assert.match(readme, /\[.*REST-API.*\]\(docs\/REST-API\.md\)/i); assert.doesNotMatch(readme, /^## REST-API$/m); assert.doesNotMatch(readme, /curl .*\/api\//); for (const endpoint of [ 'GET /api/health', 'GET /api/routes', 'GET /api/routes/:id', 'GET /api/routes/:id/pois', 'GET /api/pois/:id', 'POST /api/routes', 'PUT /api/routes/:id', 'POST /api/routes/:id/append', 'POST /api/routes/:id/pois', 'PUT /api/pois/:id', 'DELETE /api/routes/:id', 'POST /api/routes/:id/restore' ]) { assert.ok(api.includes(endpoint), `missing API documentation: ${endpoint}`); } for (const parameter of [ 'lat', 'lon', 'radiusKm', 'includeDeleted', 'gpx', 'name', 'slug', 'description', 'schoolName', 'title', 'triggerRadiusM', 'sequence', 'audio', 'images' ]) { assert.match(api, new RegExp(`\\b${parameter}\\b`), `missing parameter documentation: ${parameter}`); } });