Add tileset param validation in tile server
This commit is contained in:
parent
2b1b553a41
commit
269e6ba989
@ -129,6 +129,7 @@ function getHighlightDataConfig(tileset: string, dataParams: any): DataConfig {
|
||||
}
|
||||
|
||||
export {
|
||||
BUILDING_LAYER_DEFINITIONS,
|
||||
getBuildingsDataConfig,
|
||||
getHighlightDataConfig
|
||||
};
|
||||
|
@ -6,7 +6,12 @@ import { BranchingRenderer } from "./renderers/branchingRenderer";
|
||||
import { WindowedRenderer } from "./renderers/windowedRenderer";
|
||||
import { BlankRenderer } from "./renderers/blankRenderer";
|
||||
import { DatasourceRenderer } from "./renderers/datasourceRenderer";
|
||||
import { getBuildingsDataConfig, getHighlightDataConfig } from "./dataDefinition";
|
||||
import { getBuildingsDataConfig, getHighlightDataConfig, BUILDING_LAYER_DEFINITIONS } from "./dataDefinition";
|
||||
|
||||
/**
|
||||
* A list of all tilesets handled by the tile server
|
||||
*/
|
||||
const allTilesets = ['highlight', ...Object.keys(BUILDING_LAYER_DEFINITIONS)];
|
||||
|
||||
const buildingDataRenderer = new DatasourceRenderer(getBuildingsDataConfig);
|
||||
|
||||
@ -67,6 +72,7 @@ const mainRenderer = new WindowedRenderer(
|
||||
);
|
||||
|
||||
export {
|
||||
allTilesets,
|
||||
mainRenderer,
|
||||
tileCache
|
||||
};
|
@ -7,7 +7,7 @@ import express from 'express';
|
||||
|
||||
import { strictParseInt } from '../parse';
|
||||
import { TileParams } from './types';
|
||||
import { mainRenderer } from './rendererDefinition';
|
||||
import { mainRenderer, allTilesets } from './rendererDefinition';
|
||||
import asyncController from '../api/routes/asyncController';
|
||||
|
||||
const handleTileRequest = asyncController(async function (req: express.Request, res: express.Response) {
|
||||
@ -37,6 +37,8 @@ router.get('/:tileset/:z/:x/:y(\\d+):scale(@\\dx)?.png', handleTileRequest);
|
||||
function parseTileParams(params: any): TileParams {
|
||||
const { tileset, z, x, y, scale } = params;
|
||||
|
||||
if (!allTilesets.includes(tileset)) throw new Error('Invalid value for tileset');
|
||||
|
||||
const intZ = strictParseInt(z);
|
||||
if (isNaN(intZ)) throw new Error('Invalid value for z');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user