const fastify = require('fastify')({ logger: true });
const port = 8080;
// Declare a route
fastify.get('/', async (request, reply) => {
return { hello: 'Hello World from Fastify!' };
});
// Run the server
const start = async () => {
try {
await fastify.listen({ port });
fastify.log.info(`Fastify server running at http://localhost:${port}`);
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
};
start();
{ "hello": "Hello World from Fastify!" }