Skip to content

Instantly share code, notes, and snippets.

@WoolDoughnut310
Created October 28, 2022 15:19
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 WoolDoughnut310/6fc7ea150cace8f9606b61b8b195510c to your computer and use it in GitHub Desktop.
Save WoolDoughnut310/6fc7ea150cace8f9606b61b8b195510c to your computer and use it in GitHub Desktop.
router.get(
"/:id",
asyncHandler(async (req: Request, res: Response) => {
const db = getDb();
const collection = db.collection<Song>("song");
const song = await collection.findOne({
_id: new ObjectId(req.params.id),
});
if (song === null) {
res.status(404).send("Song not found");
return;
}
res.status(200).json(song);
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment