본문 바로가기
BE/Node

[Node] Fastify

by Chars4785 2020. 3. 13.
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 

'BE > Node' 카테고리의 다른 글

Nest.js(1)  (0) 2021.11.12
[Mongoose] 스키마  (0) 2021.09.24
[Server] MicroServices  (0) 2020.03.06
[Socket] 웹 소켓  (0) 2020.02.11
[ Node ] npm  (0) 2019.09.25

댓글