Skip to content

Instantly share code, notes, and snippets.

@PierBover
Last active May 27, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PierBover/ec87144fafa9b4ee65c1937e13364de1 to your computer and use it in GitHub Desktop.
Save PierBover/ec87144fafa9b4ee65c1937e13364de1 to your computer and use it in GitHub Desktop.
// init
const fastify = require('fastify')({
ignoreTrailingSlash: true,
logger: true
});
fastify.route({
method: 'GET',
url: '/',
handler: (request, reply) => {
reply.header('Content-Type', 'text/html');
reply.send('Hello Fastify!');
}
});
fastify.listen(process.env.PORT || 3000, '::', function (err, address) {
if (err) {
fastify.log.error(err)
process.exit(1)
}
fastify.log.info(`server listening on ${address}`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment