included serverside mime detection
Sonarqube Scanner / Build and analyze (push) Successful in 1m6s

This commit is contained in:
Florian Zumpe
2026-06-17 11:42:43 +02:00
parent 3b3069ca8c
commit 0def9b23db
11 changed files with 574 additions and 126 deletions
+8 -6
View File
@@ -26,6 +26,7 @@ test('complete REST API documentation is kept outside the README', async () => {
'POST /api/routes/:id/append',
'POST /api/routes/:id/pois',
'PUT /api/routes/:routeId/pois/:poiId',
'DELETE /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',
@@ -45,7 +46,7 @@ test('complete REST API documentation is kept outside the README', async () => {
'lat', 'lon', 'radiusKm', 'includeDeleted', 'gpx', 'name', 'slug',
'description', 'schoolName', 'title', 'triggerRadiusM', 'sequence',
'picture', 'pictureId', 'caption', 'audio', 'poiId', 'metadata',
'filename', 'contentType', 'base64', 'dataUrl'
'filename', 'base64', 'dataUrl'
]) {
assert.match(api, new RegExp(`\\b${parameter}\\b`), `missing parameter documentation: ${parameter}`);
}
@@ -57,17 +58,18 @@ test('POI media uploads use POI-scoped single-resource endpoints', async () => {
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'\), jsonUpload\('picture'\)/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/pictures\/:pictureId', upload\.single\('picture'\), jsonUpload\('picture'\)/);
assert.match(router, /post\('\/routes\/:routeId\/pois\/:poiId\/pictures', upload\.single\('picture'\), inspectUpload\('picture', 'picture'/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/pictures\/:pictureId', upload\.single\('picture'\), inspectUpload\('picture', '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'\), jsonUpload\('audio'\)/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\), jsonUpload\('audio'\)/);
assert.match(router, /post\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\), inspectUpload\('audio', 'audio'/);
assert.match(router, /put\('\/routes\/:routeId\/pois\/:poiId\/audio', upload\.single\('audio'\), inspectUpload\('audio', '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.match(router, /delete\('\/routes\/:routeId\/pois\/:poiId'/);
assert.doesNotMatch(router, /['"]\/pois\/:id['"]/);
assert.doesNotMatch(routesService, /files\.images|files\.audio/);
assert.match(mediaService, /caption/);
@@ -78,7 +80,7 @@ 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(router, /inspectUpload/);
assert.match(api, /Content-Type: `application\/json`/);
assert.match(api, /`text\/json`/);
assert.match(api, /Base64/);