Skip to content

Commit

Permalink
Include RawBodyError in types.ts
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
OlliV committed Apr 24, 2020
1 parent f9cff72 commit d29d301
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Packages
import bytes from 'bytes';
import { RawBodyError } from 'raw-body';
import { RawBodyError } from './types';

export class MicriError extends Error {
statusCode: number;
Expand Down
31 changes: 31 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,34 @@ export interface IncomingOpts {
limit?: string | number;
encoding?: string | null;
}

// The following type is borrowed from raw-body to avoid depending on the whole
// library twice just for proper typing.
export interface RawBodyError extends Error {
/**
* The limit in bytes.
*/
limit?: number;
/**
* The expected length of the stream.
*/
length?: number;
expected?: number;
/**
* The received bytes.
*/
received?: number;
/**
* The encoding.
*/
encoding?: string;
/**
* The corresponding status code for the error.
*/
status: number;
statusCode: number;
/**
* The error type.
*/
type: string;
}

0 comments on commit d29d301

Please sign in to comment.