Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export abstract class Command<
CommandInput extends JsonifiableObject | unknown = unknown,
CommandOutput extends Jsonifiable | unknown = unknown,
CommandQuery extends JsonifiableObject | unknown = unknown,
CommandHeaders extends Record<string, string | number | boolean> = Record<string, string>,
> {
public readonly method: HttpMethod = "get";

Expand All @@ -30,12 +31,15 @@ export abstract class Command<

public readonly query: CommandQuery | undefined;

public readonly headers: CommandHeaders | undefined;

protected middleware: Middleware<CommandInput, CommandOutput>[] = [];

constructor(pathname: string, body: Body | null = null, query?: CommandQuery) {
constructor(pathname: string, body: Body | null = null, query?: CommandQuery, headers?: CommandHeaders) {
this.pathname = pathname;
this.body = body;
this.query = maybeWithNullProto(query);
this.headers = headers;
}

public serialize() {
Expand Down
7 changes: 7 additions & 0 deletions lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type * as v from 'valibot';

export class ServiceError extends CustomError {

override code = CustomError.UNAVAILABLE;

public response: Response;

constructor(message: string, response: Response) {
Expand All @@ -14,6 +16,8 @@ export class ServiceError extends CustomError {

export class ServiceResponseError extends CustomError {

override code = CustomError.UNAVAILABLE;

public response: Response;

constructor(response: Response) {
Expand All @@ -23,6 +27,9 @@ export class ServiceResponseError extends CustomError {
}

export class PublicValibotHonoError extends CustomError {

override code = CustomError.INVALID_ARGUMENT;

static from(
err: v.ValiError<
| v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>
Expand Down
1 change: 1 addition & 0 deletions lib/rest-service-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class RestServiceClient<

headers: await resolveHeaders({
...this.#headers,
...command.headers,
...runtimeOptions?.headers,
}),
...(runtimeOptions?.signal && { signal: runtimeOptions?.signal }),
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
},
"dependencies": {
"@block65/custom-error": "^14.0.0",
"p-retry": "^7.1.1"
"p-retry": "^8.0.0"
},
"devDependencies": {
"@tsconfig/node24": "^24.0.0",
"@tsconfig/strictest": "^2.0.0",
"@types/node": "^24.0.0",
"eslint": "^9.0.0",
"get-port": "^7.1.0",
"type-fest": "^5.0.0",
"typescript": "^5.8.0",
"valibot": "^1.0.0",
"vitest": "^3.0.0"
"@tsconfig/node24": "^24.0.4",
"@tsconfig/strictest": "^2.0.8",
"@types/node": "^25.5.2",
"eslint": "^10.2.0",
"get-port": "^7.2.0",
"type-fest": "^5.5.0",
"typescript": "^6.0.2",
"valibot": "^1.3.1",
"vitest": "^4.1.4"
},
"engines": {
"node": ">=24.0.0"
Expand Down
Loading
Loading