Skip to content

Commit

Permalink
feat: allow json parse to be skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
sashalikesplanes committed Jan 16, 2025
1 parent 3cb474a commit 0e77644
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions api-strategy/src/strategies/http-abstract-call.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IApiCallStrategy } from '../context-call.interface.js';

export interface IHttpCallStrategyOptions {
headersWhitelist?: string[];
shouldSkipJsonParse?: (body: string) => boolean;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion api-strategy/src/strategies/nest-local-call.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ export class NestLocalCallStrategy extends HttpAbstractStrategy {

let data;
try {
data = result.json();
if (
this.options.shouldSkipJsonParse &&
this.options.shouldSkipJsonParse(result.body)
) {
data = result.body;
} else {
data = result.json();
}
} catch (_e) {
//The content-type of the response is not application/json
// if so, we use the body instead
Expand Down

0 comments on commit 0e77644

Please sign in to comment.