Skip to content

Commit

Permalink
Swagger, reply
Browse files Browse the repository at this point in the history
  • Loading branch information
PsyChonek committed Feb 28, 2025
1 parent 822b391 commit 8e806c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions services/api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ await fastify.register(fastifySwaggerUI, {
return swaggerObject;
},
transformSpecificationClone: true,
allowedHosts: ['http://localhost:3000'], // Allow HTTP
});

const PORT = process.env.PORT || 27017;
Expand Down Expand Up @@ -105,7 +106,7 @@ fastify.post(

const newReading = { espID, temperature, humidity, timestamp: new Date(timestampNew) };
const result = await readings.insertOne(newReading);
return result;
reply.send(result);
}
);

Expand Down Expand Up @@ -166,7 +167,7 @@ fastify.get(
delete reading._id;
});

return result;
reply.send(result);
} catch (error) {
console.error("Error querying MongoDB:", error);
reply.code(500).send({ error: "Failed to fetch readings." });
Expand Down Expand Up @@ -214,7 +215,7 @@ fastify.post(
}

const result = await sensors.insertOne(newSensor);
return result;
reply.send(result);
}
);

Expand Down Expand Up @@ -257,7 +258,7 @@ fastify.get(
});

console.log(result);
return result;
reply.send(result);
}
);

Expand Down

0 comments on commit 8e806c5

Please sign in to comment.