UNPKG

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