You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
497 B
TypeScript
18 lines
497 B
TypeScript
import { serverSupabaseUser, serverSupabaseClient } from '#supabase/server'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const user = await serverSupabaseUser(event)
|
|
const supabase = serverSupabaseClient(event)
|
|
|
|
if (!user) {
|
|
throw createError({ statusCode: 401, message: 'Unauthorized' })
|
|
}
|
|
|
|
const { data: notes, error } = await supabase
|
|
.from('notes')
|
|
.select('*')
|
|
.eq('user_id', user.id)
|
|
|
|
return { notes: notes, error: error }
|
|
})
|