BE/Node

[Node] Fastify

Chars4785 2020. 3. 13. 02:45
fastify.get('/', async (request, reply) => {
  return { hello: 'world' }
})

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

2가지 방법 있다.

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

// Run the server!
fastify.listen(3000, '::', function (err, address) {
    if (err) {
      fastify.log.error(err)
      process.exit(1)
    }
    fastify.log.info(`server listening on ${address}`)
})

'::' 이거나 '0.0.0.0' 은 localhost

 


Plugin

 


HTTP, TCP, SSL