Skip to content

Instantly share code, notes, and snippets.

@abhiaiyer91
Created November 13, 2018 21: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 abhiaiyer91/d23a2cb04aa3548622610937cc6710f7 to your computer and use it in GitHub Desktop.
Save abhiaiyer91/d23a2cb04aa3548622610937cc6710f7 to your computer and use it in GitHub Desktop.
/** rest of code above **/
server.get("/posts", async (_req, res) => {
// Use the posts API from prisma client
try {
const posts = await prisma.posts({
where: {
published: true
}
});
return res.send(posts).status(200);
} catch (e) {
console.error(e);
return res.sendStatus(500);
}
});
server.get("/drafts", async (_req, res) => {
// Use the posts API from prisma client
try {
const posts = await prisma.posts({
where: {
published: false
}
});
return res.send(posts).status(200);
} catch (e) {
console.error(e);
return res.sendStatus(500);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment