Replies: 1 comment
-
|
This is the best I could do using @marr answer (Im using Hono with OpenAPI) const getLocationsTiles = createRoute({
tags: ['locations'],
method: 'get',
path: '/{z}/{x}/{y}{.+\\.mvt$}', // <---- that at least gets you to something like '1234.mvt'
request: {
params: z.object({
z: z
.string()
.transform((val) => parseInt(val, 10))
.pipe(z.number().int().min(0))
.describe('Zoom level'),
x: z
.string()
.transform((val) => parseInt(val, 10))
.pipe(z.number().int().min(0))
.describe('X coordinate of the tile'),
y: z
.string()
.transform((val) => { // <-------- Here just extract the number
// Extract the number by removing the .mvt extension
const numStr = val.split('.')[0];
return parseInt(numStr, 10);
})
.pipe(z.number().int().min(0))
.describe('Y coordinate of the tile'),
}),
query: z.object({
density: z
.enum(['low', 'medium', 'high'])
.optional()
.describe('Density of the tile'),
}),
},
responses: {
200: {
content: {
'application/x-protobuf': {
schema:
locationsRepository.tiles.getLocationsTiles.outputSchema.openapi({
example: Buffer.from('I am a buffer'),
}),
},
},
description: locationsRepository.tiles.getLocationsTiles.description,
},
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to handle a route that would include a file extension as well as multiple parameters. The example request url might look like
/tile/1/2/3.mvt-- I can't figure out the correct route definition. I tried'/tile/:z/:y/:x{.+\\.mvt$}'as that is the closest thing in the documentation I could find. The parameters don't match up. Please help.Beta Was this translation helpful? Give feedback.
All reactions