Skip to content

Variable: OnParse

ts
const OnParse: (options?) => MethodDecorator;

Defined in: packages/core/src/decorators/lifecycle.decorators.ts:94

Hook called to parse request body

Parameters

ParameterTypeDescription
options?{ before?: boolean; }-
options.before?booleanInsert before other hooks

Returns

MethodDecorator

See

https://elysiajs.com/essential/life-cycle.html#on-parse

Example

typescript
@Controller('/users')
export class UserController {
  @OnParse()
  async customParser(context: Context) {
    const contentType = context.request.headers.get('content-type');
    if (contentType === 'application/custom') {
      return await context.request.text();
    }
  }
}

Released under the MIT License.