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.
16 lines
451 B
TypeScript
16 lines
451 B
TypeScript
import { serverSupabaseUser, serverSupabaseClient } from '#supabase/server';
|
|
|
|
const config = useRuntimeConfig();
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const user = await serverSupabaseUser(event);
|
|
const supabase = serverSupabaseClient(event);
|
|
|
|
const { data: notes, error } = await supabase.from('notes').select('*');
|
|
|
|
if (!user) {
|
|
throw createError({ statusCode: 401, message: 'Unauthorized' });
|
|
}
|
|
return { notes: notes };
|
|
});
|