Setu-TS
    Preparing search index...

    Function withResponseMetadata

    • Brands a route handler with the success status it answers with, 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 handler behaves exactly as it did.

      Type Parameters

      Parameters

      Returns T

      The same handler reference, branded

      const handler = withResponseMetadata(
      (ctx) => ctx.response.status(201).json({ created: true }),
      { status: 201 },
      );

      0.7.0