@adonisjs/bodyparser
Version:
AdonisJs body parser to read and parse HTTP request bodies
45 lines (44 loc) • 1.44 kB
TypeScript
/// <reference path="../../adonis-typings/bodyparser.d.ts" />
/// <reference types="@adonisjs/config/build/adonis-typings/config" />
import type { ConfigContract } from '@ioc:Adonis/Core/Config';
import type { DriveManagerContract } from '@ioc:Adonis/Core/Drive';
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
/**
* BodyParser middleware parses the incoming request body and set it as
* request body to be read later in the request lifecycle.
*/
export declare class BodyParserMiddleware {
private drive;
/**
* Bodyparser config
*/
private config;
constructor(Config: ConfigContract, drive: DriveManagerContract);
/**
* Returns config for a given type
*/
private getConfigFor;
/**
* Ensures that types exists and have length
*/
private ensureTypes;
/**
* Returns a boolean telling if request `content-type` header
* matches the expected types or not
*/
private isType;
/**
* Returns a proper Adonis style exception for popular error codes
* returned by https://github.com/stream-utils/raw-body#readme.
*/
private getExceptionFor;
/**
* Returns the tmp path for storing the files temporarly
*/
private getTmpPath;
/**
* Handle HTTP request body by parsing it as per the user
* config
*/
handle(ctx: HttpContextContract, next: () => Promise<void>): Promise<void>;
}