chore: code cleanuo
This commit is contained in:
@@ -6,26 +6,25 @@ const fastify = Fastify();
|
|||||||
|
|
||||||
// Change this later
|
// Change this later
|
||||||
const corsOptions = {
|
const corsOptions = {
|
||||||
origin: 'http://localhost:5173'
|
origin: 'http://localhost:5173'
|
||||||
}
|
}
|
||||||
|
|
||||||
await fastify.register(cors, corsOptions)
|
await fastify.register(cors, corsOptions)
|
||||||
|
|
||||||
fastify.get('/', async (request, reply) => {
|
fastify.get('/', async (request, reply) => {
|
||||||
reply.send('Hello Word!');
|
reply.send('Vroom Vroom Vroom');
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.post('/scrape', async (request, reply) => {
|
fastify.post('/scrape', async (request, reply) => {
|
||||||
const { url, selectors } = request.body;
|
const { url, selectors } = request.body;
|
||||||
try {
|
try {
|
||||||
const response = await scrapeData(url, selectors);
|
const response = await scrapeData(url, selectors);
|
||||||
reply.send(response);
|
reply.send(response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reply.status(500).send({ error: error.message });
|
reply.status(500).send({ error: error.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
await fastify.listen(3000, (err, address) => {
|
await fastify.listen(3000, (err, address) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log(`Server listening on ${fastify.server.address().port}`)
|
console.log(`Server listening on ${fastify.server.address().port}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user