Setu-TS
    Preparing search index...

    Function withSecurityMetadata

    • Brands a middleware function with the security it enforces, so a documentation generator can read it without importing the plugin that produced it.

      The function is branded in place and returned, so identity is preserved and the brand costs no wrapper frame per request. The property is symbol-keyed and non-enumerable, so it is invisible to Object.keys, JSON.stringify and spread, and the middleware behaves exactly as it did.

      Type Parameters

      Parameters

      Returns T

      The same middleware reference, branded

      export function requireAuth(): MiddlewareFunction {
      return withSecurityMetadata(async (ctx, next) => {
      if (!ctx.request.user) return void ctx.response.status(401).json({ error: 'Unauthorized' });
      await next();
      }, { authenticated: true });
      }

      0.2.0