1// Quick start
2// Get fastify with NPM:
3// npm install fastify
4
5// Require the framework and instantiate it
6const fastify = require('fastify')({ logger: true })
7
8// Declare a route
9fastify.get('/', async (request, reply) => {
10 return { hello: 'world' }
11})
12
13// Run the server!
14const start = async () => {
15 try {
16 await fastify.listen(3000)
17 } catch (err) {
18 fastify.log.error(err)
19 process.exit(1)
20 }
21}
22start()
23
24// in the console: node server
25
26// test: curl http://localhost:3000
27
28