-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-fsf.js
75 lines (57 loc) · 1.87 KB
/
index-fsf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const fastify = require('fastify');
const server = fastify({
ignoreTrailingSlash: true,
});
server.get('/static/param1', (request, reply) => {
reply.send('param1');
});
server.get('/static/param2', (request, reply) => {
reply.send('param2');
});
server.get('/static/:paramA/next', (request, reply) => {
reply.send({ route: 'next', ...request.params });
});
server.get('/static/param1/next/param3', (request, reply) => {
reply.send('param1-3');
});
server.get('/static/param1/next/param4', (request, reply) => {
reply.send('param1-4');
});
server.get('/static/:paramA/next/:paramB/next', (request, reply) => {
reply.send({ route: 'next', ...request.params });
});
server.get('/static/:paramA/next/:paramB/other', (request, reply) => {
reply.send({ route: 'other', ...request.params });
});
server.get('/static/param1/next/param2/other/param3', (request, reply) => {
reply.send('param1-2-3');
});
server.get('/static/param1/next/param2/other/param4', (request, reply) => {
reply.send('param1-2-4');
});
server.get('/static/:paramA/next/:paramB/other/:paramC/last', (request, reply) => {
reply.send({ route: 'other', ...request.params });
});
server.get('/dynamic/param1', (request, reply) => {
reply.send('param1');
});
server.get('/dynamic/param2', (request, reply) => {
reply.send('param2');
});
server.get('/dynamic/:paramA/next', (request, reply) => {
reply.send({ route: 'next', ...request.params });
});
server.get('/dynamic/:paramA/next/param3', (request, reply) => {
reply.send('paramA-3');
});
server.get('/dynamic/:paramA/next/param4', (request, reply) => {
reply.send('paramA-4');
});
server.get('/dynamic/:paramA/next/:paramB/other', (request, reply) => {
reply.send({ route: 'next', ...request.params });
});
server.listen(3111, (err) => {
if (err) throw err;
console.log('Server listening on port 3111');
console.log(server.printRoutes());
});