Skip to content

Commit 70cd672

Browse files
wip
1 parent f876bf4 commit 70cd672

File tree

4 files changed

+214
-190
lines changed

4 files changed

+214
-190
lines changed

server/schema.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.tripSchema = exports.matchSchema = exports.tableSchema = exports.nearestSchema = exports.routeSchema = void 0;
3+
exports.tileSchema = exports.tripSchema = exports.matchSchema = exports.tableSchema = exports.nearestSchema = exports.routeSchema = void 0;
44
const queryStringJsonSchemaGeneral = {
55
type: 'object',
66
properties: {
@@ -174,3 +174,14 @@ exports.matchSchema = {
174174
exports.tripSchema = {
175175
querystring: queryStringJsonSchemaTrip,
176176
};
177+
const paramsJsonSchemaTile = {
178+
type: 'object',
179+
properties: {
180+
z: { type: 'integer', minimum: 12, maximum: 22 },
181+
x: { type: 'integer', minimum: 0 },
182+
y: { type: 'integer', minimum: 0 },
183+
},
184+
};
185+
exports.tileSchema = {
186+
params: paramsJsonSchemaTile,
187+
};

server/schema.ts

Lines changed: 165 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,200 @@
11
const queryStringJsonSchemaGeneral = {
22
type: 'object',
33
properties: {
4-
bearings: {
5-
type: 'string',
6-
// TODO: pattern
7-
},
8-
radiuses: {
9-
type: 'string',
10-
// TODO: pattern
11-
},
12-
generate_hints: { type: 'boolean', default: true },
13-
hints: {
14-
type: 'string',
15-
// TODO: pattern
16-
},
17-
approaches: {
18-
type: 'string',
19-
// TODO: pattern
20-
},
21-
exclude: {
22-
type: 'string',
23-
// TODO: pattern
24-
},
25-
snapping: {
26-
enum: ['any', 'default'],
27-
default: 'default'
28-
},
29-
skip_waypoints: { type: 'boolean', default: false },
4+
bearings: {
5+
type: 'string',
6+
// TODO: pattern
7+
},
8+
radiuses: {
9+
type: 'string',
10+
// TODO: pattern
11+
},
12+
generate_hints: { type: 'boolean', default: true },
13+
hints: {
14+
type: 'string',
15+
// TODO: pattern
16+
},
17+
approaches: {
18+
type: 'string',
19+
// TODO: pattern
20+
},
21+
exclude: {
22+
type: 'string',
23+
// TODO: pattern
24+
},
25+
snapping: {
26+
enum: ['any', 'default'],
27+
default: 'default'
28+
},
29+
skip_waypoints: { type: 'boolean', default: false },
3030
}
31-
};
31+
};
3232

33-
const queryStringJsonSchemaRoute = {
33+
const queryStringJsonSchemaRoute = {
3434
type: 'object',
3535
properties: {
36-
...queryStringJsonSchemaGeneral.properties,
37-
alternatives: { type: ['boolean', 'integer'], default: false },
38-
steps: { type: 'boolean', default: false },
39-
annotations: {
40-
type: 'string',
41-
// TODO: pattern
42-
},
43-
geometries: {
44-
enum: ['polyline', 'polyline6', 'geojson'],
45-
default: 'polyline'
46-
},
47-
overview: {
48-
enum: ['simplified', 'full', 'false'],
49-
default: 'simplified'
50-
},
51-
continue_straight: {
52-
type: 'string',
53-
// TODO:
54-
},
55-
waypoints: {
56-
type: 'string',
57-
// list of numbers separated by semicolon
58-
pattern: '^(\\d+(;\\d+)*)?$'
59-
}
36+
...queryStringJsonSchemaGeneral.properties,
37+
alternatives: { type: ['boolean', 'integer'], default: false },
38+
steps: { type: 'boolean', default: false },
39+
annotations: {
40+
type: 'string',
41+
// TODO: pattern
42+
},
43+
geometries: {
44+
enum: ['polyline', 'polyline6', 'geojson'],
45+
default: 'polyline'
46+
},
47+
overview: {
48+
enum: ['simplified', 'full', 'false'],
49+
default: 'simplified'
50+
},
51+
continue_straight: {
52+
type: 'string',
53+
// TODO:
54+
},
55+
waypoints: {
56+
type: 'string',
57+
// list of numbers separated by semicolon
58+
pattern: '^(\\d+(;\\d+)*)?$'
59+
}
6060
}
61-
}
61+
}
6262

63-
const queryStringJsonSchemaNearest = {
63+
const queryStringJsonSchemaNearest = {
6464
type: 'object',
6565
properties: {
66-
...queryStringJsonSchemaGeneral.properties,
67-
alternatives: { type: ['integer'], default: 1 }
66+
...queryStringJsonSchemaGeneral.properties,
67+
alternatives: { type: ['integer'], default: 1 }
6868
}
69-
}
69+
}
7070

71-
const queryStringJsonSchemaTable = {
71+
const queryStringJsonSchemaTable = {
7272
type: 'object',
7373
properties: {
74-
...queryStringJsonSchemaGeneral.properties,
75-
// TODO: all
76-
sources: {
77-
type: 'string',
78-
// list of numbers separated by semicolon
79-
pattern: '^(\\d+(;\\d+)*)?$'
80-
},
81-
// TODO: all
82-
destinations: {
83-
type: 'string',
84-
// list of numbers separated by semicolon
85-
pattern: '^(\\d+(;\\d+)*)?$'
86-
},
87-
annotations: {
88-
type: 'string',
89-
// TODO: pattern
90-
},
91-
fallback_speed: {
92-
type: 'number',
93-
exclusiveMinimum: 0
94-
},
95-
fallback_coordinate: {
96-
enum: ['input', 'snapped'],
97-
default: 'input'
98-
},
99-
scale_factor: {
100-
type: 'number',
101-
exclusiveMinimum: 0
102-
}
74+
...queryStringJsonSchemaGeneral.properties,
75+
// TODO: all
76+
sources: {
77+
type: 'string',
78+
// list of numbers separated by semicolon
79+
pattern: '^(\\d+(;\\d+)*)?$'
80+
},
81+
// TODO: all
82+
destinations: {
83+
type: 'string',
84+
// list of numbers separated by semicolon
85+
pattern: '^(\\d+(;\\d+)*)?$'
86+
},
87+
annotations: {
88+
type: 'string',
89+
// TODO: pattern
90+
},
91+
fallback_speed: {
92+
type: 'number',
93+
exclusiveMinimum: 0
94+
},
95+
fallback_coordinate: {
96+
enum: ['input', 'snapped'],
97+
default: 'input'
98+
},
99+
scale_factor: {
100+
type: 'number',
101+
exclusiveMinimum: 0
102+
}
103103
}
104-
}
104+
}
105105

106106

107-
const queryStringJsonSchemaMatch = {
107+
const queryStringJsonSchemaMatch = {
108108
type: 'object',
109109
properties: {
110-
...queryStringJsonSchemaGeneral.properties,
111-
112-
steps: { type: 'boolean', default: false },
113-
114-
geometries: {
115-
enum: ['polyline', 'polyline6', 'geojson'],
116-
default: 'polyline'
117-
},
118-
timestamps: {
119-
type: 'string',
120-
// list of numbers separated by semicolon
121-
pattern: '^(\\d+(;\\d+)*)?$'
122-
},
123-
overview: {
124-
enum: ['simplified', 'full', 'false'],
125-
default: 'simplified'
126-
},
127-
gaps: {
128-
enum: ['split', 'ignore'],
129-
default: 'split'
130-
},
131-
tidy: { type: 'boolean', default: false },
132-
waypoints: {
133-
type: 'string',
134-
// list of numbers separated by semicolon
135-
pattern: '^(\\d+(;\\d+)*)?$'
136-
},
110+
...queryStringJsonSchemaGeneral.properties,
111+
112+
steps: { type: 'boolean', default: false },
113+
114+
geometries: {
115+
enum: ['polyline', 'polyline6', 'geojson'],
116+
default: 'polyline'
117+
},
118+
timestamps: {
119+
type: 'string',
120+
// list of numbers separated by semicolon
121+
pattern: '^(\\d+(;\\d+)*)?$'
122+
},
123+
overview: {
124+
enum: ['simplified', 'full', 'false'],
125+
default: 'simplified'
126+
},
127+
gaps: {
128+
enum: ['split', 'ignore'],
129+
default: 'split'
130+
},
131+
tidy: { type: 'boolean', default: false },
132+
waypoints: {
133+
type: 'string',
134+
// list of numbers separated by semicolon
135+
pattern: '^(\\d+(;\\d+)*)?$'
136+
},
137137
}
138-
}
138+
}
139139

140-
const queryStringJsonSchemaTrip = {
140+
const queryStringJsonSchemaTrip = {
141141
type: 'object',
142142
properties: {
143-
...queryStringJsonSchemaGeneral.properties,
144-
145-
roundtrip: { type: 'boolean', default: true },
146-
source: {
147-
enum: ['any', 'first'],
148-
default: 'any'
149-
},
150-
destination: {
151-
enum: ['any', 'last'],
152-
default: 'any'
153-
},
154-
annotations: {
155-
type: 'string',
156-
// TODO: pattern
157-
},
158-
geometries: {
159-
enum: ['polyline', 'polyline6', 'geojson'],
160-
default: 'polyline'
161-
},
162-
overview: {
163-
enum: ['simplified', 'full', 'false'],
164-
default: 'simplified'
165-
}
143+
...queryStringJsonSchemaGeneral.properties,
144+
145+
roundtrip: { type: 'boolean', default: true },
146+
source: {
147+
enum: ['any', 'first'],
148+
default: 'any'
149+
},
150+
destination: {
151+
enum: ['any', 'last'],
152+
default: 'any'
153+
},
154+
annotations: {
155+
type: 'string',
156+
// TODO: pattern
157+
},
158+
geometries: {
159+
enum: ['polyline', 'polyline6', 'geojson'],
160+
default: 'polyline'
161+
},
162+
overview: {
163+
enum: ['simplified', 'full', 'false'],
164+
default: 'simplified'
165+
}
166166
}
167-
}
167+
}
168168

169-
export const routeSchema = {
169+
export const routeSchema = {
170170
querystring: queryStringJsonSchemaRoute,
171-
}
171+
}
172172

173173

174-
export const nearestSchema = {
174+
export const nearestSchema = {
175175
querystring: queryStringJsonSchemaNearest,
176-
}
176+
}
177177

178-
export const tableSchema = {
178+
export const tableSchema = {
179179
querystring: queryStringJsonSchemaTable,
180-
}
180+
}
181181

182-
export const matchSchema = {
182+
export const matchSchema = {
183183
querystring: queryStringJsonSchemaMatch,
184-
}
185-
export const tripSchema = {
184+
}
185+
export const tripSchema = {
186186
querystring: queryStringJsonSchemaTrip,
187-
}
187+
}
188+
189+
const paramsJsonSchemaTile = {
190+
type: 'object',
191+
properties: {
192+
z: { type: 'integer', minimum: 12, maximum: 22 },
193+
x: { type: 'integer', minimum: 0 },
194+
y: { type: 'integer', minimum: 0 },
195+
},
196+
};
197+
198+
export const tileSchema = {
199+
params: paramsJsonSchemaTile,
200+
};

server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ async function main() {
329329
fastify.get('/trip/v1/:profile/:coordinatesAndFormat', { schema: schema_1.tripSchema }, async (request, reply) => {
330330
return processRequest(handleTrip, request, reply);
331331
});
332-
fastify.get('/tile/v1/:profile/tile(:x,:y,:zoom).mvt', async (request, reply) => {
332+
fastify.get('/tile/v1/:profile/tile(:x,:y,:zoom).mvt', { schema: schema_1.tileSchema }, async (request, reply) => {
333333
const { x, y, zoom } = request.params;
334334
reply.type('application/x-protobuf').code(200);
335335
return tile(osrm, [zoom, x, y]);

0 commit comments

Comments
 (0)