first commit

This commit is contained in:
2026-04-14 19:44:21 -05:00
commit 068576cf4b
36 changed files with 13680 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { createError, type H3Event } from 'h3'
import type { AuthContext } from '../types/auth'
/**
* Garante que o middleware de autenticação já preencheu `event.context.auth`.
*
* @param event Evento HTTP atual.
* @returns Contexto autenticado com ID do usuário e token.
* @throws {H3Error} Quando a requisição não estiver autenticada.
*/
export function requireAuthContext(event: H3Event): AuthContext {
if (!event.context.auth) {
throw createError({ statusCode: 401, statusMessage: 'Authentication required' })
}
return event.context.auth
}