@@ -17,10 +17,7 @@ import {
1717 */
1818export function getRoutes ( options ) {
1919 return [
20- // mapSourceRoute(options),
21- // mapStyleRoute(options),
2220 mapStyleResourceRoutes ( ) ,
23- // mapProxy2Route(options),
2421 mapProxyRoute ( options ) ,
2522 tileProxyRoute ( options ) ,
2623 geocodeProxyRoute ( options ) ,
@@ -190,113 +187,6 @@ function mapStyleResourceRoutes() {
190187 }
191188}
192189
193- // /**
194- // * Proxies ordnance survey requests from the front end to api.os.uk
195- // * Used for source requests by forwarding on the request and adding the auth token
196- // * @param {MapConfiguration } options - the map options
197- // * @returns {ServerRoute<MapProxyGetRequestRefs> }
198- // */
199- // function mapSourceRoute(options) {
200- // return {
201- // method: 'GET',
202- // path: '/api/source',
203- // handler: async (request, h) => {
204- // const token = await getAccessToken(options)
205-
206- // const proxyResponse = await get('https://api.os.uk/maps/vector/v1/vts', {
207- // json: true,
208- // headers: {
209- // Authorization: `Bearer ${token}`
210- // }
211- // })
212-
213- // // Rewrite the tile URL from https://api.os.uk/maps/vector/v1/vts/tile/{z}/{y}/{x}.pbf?srs=3857
214- // const tilePath = request.route.path.replace('source', 'tile')
215- // proxyResponse.payload.tiles[0] = `${request.url.origin}${tilePath}/{z}/{y}/{x}.pbf?srs=3857`
216-
217- // return proxyResponse.payload
218- // }
219- // }
220- // }
221-
222- // /**
223- // * Returns the styles with rewritten URLs
224- // * @param {MapConfiguration } options - the map options
225- // * @returns {ServerRoute<MapProxyGetRequestRefs> }
226- // */
227- // function mapStyleRoute(options) {
228- // return {
229- // method: 'GET',
230- // path: '/api/style/{style}.json',
231- // handler: async (request, h) => {
232- // const { params } = request
233- // const { style } = params
234-
235- // const sources = {
236- // esri: {
237- // type: 'vector',
238- // url: `${request.url.origin}/form/api/source`
239- // }
240- // }
241-
242- // const spritePath = request.route.path.replace(
243- // 'style/{style}.json',
244- // 'maps/vts/OS_VTS_3857/resources/sprites/sprite'
245- // )
246-
247- // return {
248- // ...styles[style],
249- // glyphs: '/form/api/proxy/resources/fonts/{fontstack}/{range}.pbf',
250- // sprite: `${request.url.origin}${spritePath}`,
251- // // sources
252- // }
253- // },
254- // options: {
255- // validate: {
256- // params: Joi.object()
257- // .keys({
258- // style: Joi.string()
259- // .valid(...Object.keys(styles))
260- // .required()
261- // })
262- // .required()
263- // }
264- // }
265- // }
266- // }
267-
268- // /**
269- // * Proxies ordnance survey requests from the front end to api.os.uk
270- // * @param {MapConfiguration } options - the map options
271- // * @returns {ServerRoute<MapProxyGetRequestRefs> }
272- // */
273- // function mapProxy2Route(options) {
274- // return {
275- // method: 'GET',
276- // path: '/api/proxy/{path*}',
277- // handler: async (request, h) => {
278- // const token = await getAccessToken(options)
279- // const proxyResponse = await get(
280- // `https://api.os.uk/maps/vector/v1/vts/${request.params.path}`,
281- // {
282- // headers: {
283- // Authorization: `Bearer ${token}`
284- // }
285- // }
286- // )
287- // const buffer = proxyResponse.payload
288- // const contentType = proxyResponse.res.headers['content-type']
289- // const response = h.response(buffer)
290-
291- // if (contentType) {
292- // response.type(contentType)
293- // }
294-
295- // return response
296- // }
297- // }
298- // }
299-
300190/**
301191 * @import { ServerRoute } from '@hapi/hapi'
302192 * @import { MapConfiguration, MapProxyGetRequestRefs, MapGeocodeGetRequestRefs, MapReverseGeocodeGetRequestRefs } from '~/src/server/plugins/map/types.js'
0 commit comments