add authentication

This commit is contained in:
Kurt Hutten
2020-10-13 07:45:53 +11:00
parent 6842450288
commit 5379516128
7 changed files with 179 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
import { db } from 'src/lib/db'
import { requireAuth } from 'src/lib/auth'
export const posts = () => {
return db.post.findMany()
@@ -11,12 +12,14 @@ export const post = ({ id }) => {
}
export const createPost = ({ input }) => {
requireAuth()
return db.post.create({
data: input,
})
}
export const updatePost = ({ id, input }) => {
requireAuth()
return db.post.update({
data: input,
where: { id },
@@ -24,6 +27,7 @@ export const updatePost = ({ id, input }) => {
}
export const deletePost = ({ id }) => {
requireAuth()
return db.post.delete({
where: { id },
})