Adds authentication

This commit is contained in:
Rob Cameron
2020-10-07 14:45:51 -07:00
parent 35456b0a4d
commit 2941c967ad
8 changed files with 189 additions and 9 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 },
})