Answers for "fastify"

0

fastify

// Quick start
// Get fastify with NPM:
// npm install fastify 

// Require the framework and instantiate it
const fastify = require('fastify')({ logger: true })

// Declare a route
fastify.get('/', async (request, reply) => {
  return { hello: 'world' }
})

// Run the server!
const start = async () => {
  try {
    await fastify.listen(3000)
  } catch (err) {
    fastify.log.error(err)
    process.exit(1)
  }
}
start()

// in the console: node server

// test: curl http://localhost:3000
Posted by: Guest on September-29-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language