Skip to content

Commit

Permalink
Cleanup typings
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Dec 7, 2023
1 parent ed98ebf commit 6e09c6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface Options<Data> {
/**
* An object containing any HTTP headers where each key is a header name and value is the header content
*/
readonly headers?: { [header: string]: string | string[] | number };
readonly headers?: { [header: string]: string | readonly string[] | number };

/**
* Constructor reference used to crop the exception call stack output
Expand Down Expand Up @@ -116,17 +116,17 @@ export interface Output {
/**
* The HTTP status code
*/
readonly statusCode: number;
statusCode: number;

/**
* An object containing any HTTP headers where each key is a header name and value is the header content
*/
readonly headers: { [header: string]: string | string[] | number | undefined };
headers: { [header: string]: string | string[] | number | undefined };

/**
* The formatted object used as the response payload (stringified)
*/
readonly payload: Payload;
payload: Payload & { [key: string]: unknown };
}


Expand Down Expand Up @@ -213,7 +213,7 @@ export namespace unauthorized {
*
* @returns A 401 Unauthorized error
*/
export function unauthorized(message: string | null | undefined, wwwAuthenticate: string[]): Boom<null>;
export function unauthorized(message: string | null | undefined, wwwAuthenticate: readonly string[]): Boom<null>;


/**
Expand Down Expand Up @@ -258,7 +258,7 @@ export function notFound<Data>(message?: string, data?: Data): Boom<Data>;
*
* @returns A 405 Method Not Allowed error
*/
export function methodNotAllowed<Data>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
export function methodNotAllowed<Data>(message?: string, data?: Data, allow?: string | readonly string[]): Boom<Data>;


/**
Expand Down
5 changes: 5 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ expect.type<Boom.Boom>(new CustomError('Some error'));

const boom = new Boom.Boom('some error');
expect.type<Boom.Output>(boom.output);
boom.output.payload.custom_null = null;
boom.output.payload.custom_number = 42;
boom.output.payload.custom_string = 'foo';
boom.output.payload.custom_boolean = true;
boom.output.payload.custom_object = { bar: 42 };
boom.output.headers['header1'] = 'foo';
boom.output.headers['header2'] = ['foo', 'bar'];
boom.output.headers['header3'] = 42;
Expand Down

0 comments on commit 6e09c6f

Please sign in to comment.