1 | 'use strict'
|
2 |
|
3 | const Fastify = require('../fastify')
|
4 |
|
5 | const fastify = Fastify()
|
6 |
|
7 | fastify.listen({
|
8 | host: '::',
|
9 | port: 3000
|
10 | })
|
11 |
|
12 | fastify.get('/', async function (request, reply) {
|
13 | reply.code(200).send({ data: 'home page' })
|
14 | })
|
15 |
|
16 | fastify.post('/post/:id', async function (request, reply) {
|
17 | const { id } = request.params
|
18 | reply.code(201).send({ data: `${id}` })
|
19 | })
|
20 |
|
21 | fastify.put('/put/:id', async function (request, reply) {
|
22 | const { id } = request.params
|
23 | reply.code(200).send({ data: `${id}` })
|
24 | })
|
25 |
|
26 | fastify.delete('/delete/:id', async function (request, reply) {
|
27 | const { id } = request.params
|
28 | reply.code(204).send({ data: `${id}` })
|
29 | })
|