fix: allow tile size to be set at json endpoints

Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
Andrew Calcutt 2024-01-22 01:17:15 -05:00
parent 24f6a833ec
commit a7dc8f38a3
3 changed files with 6 additions and 6 deletions

View file

@ -168,8 +168,8 @@ export const serve_data = {
},
);
app.get('/:id.json', (req, res, next) => {
const tileSize = undefined;
app.get('/(:tileSize(256|512)/)?:id.json', (req, res, next) => {
const tileSize = parseInt(req.params.tileSize, 10) || 256;
const item = repo[req.params.id];
if (!item) {
return res.sendStatus(404);

View file

@ -822,8 +822,8 @@ export const serve_rendered = {
);
}
app.get('/:id.json', (req, res, next) => {
const tileSize = 512;
app.get('/(:tileSize(256|512)/)?:id.json', (req, res, next) => {
const tileSize = parseInt(req.params.tileSize, 10) || 256;
const item = repo[req.params.id];
if (!item) {
return res.sendStatus(404);

View file

@ -75,9 +75,9 @@ export const getTileUrls = (
format = aliases[format];
}
let tileParams = '{z}/{x}/{y}';
let tileParams = `{z}/{x}/{y}`;
if (tileSize && ['png', 'jpg', 'jpeg', 'webp'].includes(format)) {
tileParams = '{tileSize}/{z}/{x}/{y}';
tileParams = `${tileSize}/{z}/{x}/{y}`;
}
const uris = [];