fixed missing endpoint GET /routes/:id/pois/:id and added json style fileupload

This commit is contained in:
Florian Zumpe
2026-06-17 01:39:50 +02:00
parent 5c85a0194b
commit 09ce7c0605
10 changed files with 380 additions and 50 deletions
+16 -7
View File
@@ -20,12 +20,12 @@ test('complete REST API documentation is kept outside the README', async () => {
'GET /api/routes/:id',
'GET /api/routes/:id/gpx',
'GET /api/routes/:id/pois',
'GET /api/pois/:id',
'GET /api/routes/:routeId/pois/:poiId',
'POST /api/routes',
'PUT /api/routes/:id',
'POST /api/routes/:id/append',
'POST /api/routes/:id/pois',
'PUT /api/pois/:id',
'PUT /api/routes/:routeId/pois/:poiId',
'GET /api/routes/:routeId/pois/:poiId/pictures',
'GET /api/routes/:routeId/pois/:poiId/pictures/:pictureId',
'POST /api/routes/:routeId/pois/:poiId/pictures',
@@ -44,7 +44,8 @@ test('complete REST API documentation is kept outside the README', async () => {
for (const parameter of [
'lat', 'lon', 'radiusKm', 'includeDeleted', 'gpx', 'name', 'slug',
'description', 'schoolName', 'title', 'triggerRadiusM', 'sequence',
'picture', 'pictureId', 'caption', 'audio', 'poiId', 'metadata'
'picture', 'pictureId', 'caption', 'audio', 'poiId', 'metadata',
'filename', 'contentType', 'base64', 'dataUrl'
]) {
assert.match(api, new RegExp(`\\b${parameter}\\b`), `missing parameter documentation: ${parameter}`);
}
@@ -54,16 +55,20 @@ test('POI media uploads use POI-scoped single-resource endpoints', async () => {
const router = await read('src/routes/api.js');
const routesService = await read('src/services/routes-service.js');
const mediaService = await read('src/services/media-service.js');
const api = await read('docs/REST-API.md');
assert.match(router, /post\('\/routes\/:routeId\/pois\/:poiId\/pictures', upload\.single\('picture'\)/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/pictures\/:pictureId', upload\.single\('picture'\)/);
assert.match(router, /post\('\/routes\/:routeId\/pois\/:poiId\/pictures', upload\.single\('picture'\), jsonUpload\('picture'\)/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/pictures\/:pictureId', upload\.single\('picture'\), jsonUpload\('picture'\)/);
assert.match(router, /delete\('\/routes\/:routeId\/pois\/:poiId\/pictures\/:pictureId'/);
assert.match(router, /get\('\/routes\/:routeId\/pois\/:poiId\/audio'/);
assert.match(router, /post\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\)/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\)/);
assert.match(router, /post\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\), jsonUpload\('audio'\)/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\), jsonUpload\('audio'\)/);
assert.match(router, /delete\('\/routes\/:routeId\/pois\/:poiId\/audio'/);
assert.doesNotMatch(router, /\/routes\/:id\/(?:pictures|audio)/);
assert.match(router, /post\('\/routes\/:id\/pois', upload\.none\(\),/);
assert.match(router, /get\('\/routes\/:routeId\/pois\/:poiId'/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId', upload\.none\(\)/);
assert.doesNotMatch(router, /['"]\/pois\/:id['"]/);
assert.doesNotMatch(routesService, /files\.images|files\.audio/);
assert.match(mediaService, /caption/);
assert.match(mediaService, /removeStoredFile/);
@@ -73,4 +78,8 @@ test('POI media uploads use POI-scoped single-resource endpoints', async () => {
assert.doesNotMatch(router, /['"`]\/media\//);
assert.doesNotMatch(routesService, /safeMediaUrl|\/media\//);
assert.doesNotMatch(mediaService, /safeMediaUrl|\/media\//);
assert.match(router, /jsonUpload/);
assert.match(api, /Content-Type: `application\/json`/);
assert.match(api, /`text\/json`/);
assert.match(api, /Base64/);
});