whats the difference between these two examples ? And which should you prefer to use ?
import Fastify from 'fastify';
const fastify = Fastify({
logger: true
});
fastify.get('/', async () => {
return { message: 'Hello' }
});
const main = async () => {
await fastify.listen({port: 3000});
};
second
const fastify = require('fastify')({logger: true});
fastify.get('/', async (req, reply) => {
reply.send({message: 'Hello'})
});
const main = async () => {
await fastify.listen({port: 3000});
};
So in the first we use import and not reply.send
in the second I use require and reply.send
I watched two tutorials and thats why I am asking which should I use and what you prefer and whats the difference ?