add authentication
This commit is contained in:
@@ -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 },
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user