Skip to content

Commit

Permalink
Ref: reducing assignments.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Jan 1, 2024
1 parent 4342fc7 commit 4e84488
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,24 @@ export class Endpoint<
this.#scopes = scopes;
this.#tags = tags;
this.#descriptions = { long, short };
const positive = normalizeApiResponse(
resultHandler.getPositiveResponse(outputSchema),
{ mimeTypes: [mimeJson], statusCodes: [defaultStatusCodes.positive] },
);
const negative = normalizeApiResponse(resultHandler.getNegativeResponse(), {
mimeTypes: [mimeJson],
statusCodes: [defaultStatusCodes.negative],
});
this.#responses = { positive, negative };
this.#responses = {
positive: normalizeApiResponse(
resultHandler.getPositiveResponse(outputSchema),
{ mimeTypes: [mimeJson], statusCodes: [defaultStatusCodes.positive] },
),
negative: normalizeApiResponse(resultHandler.getNegativeResponse(), {
mimeTypes: [mimeJson],
statusCodes: [defaultStatusCodes.negative],
}),
};
this.#mimeTypes = {
input: hasUpload(inputSchema)
? [mimeMultipart]
: hasRaw(inputSchema)
? [mimeRaw]
: [mimeJson],
positive: positive.flatMap(({ mimeTypes }) => mimeTypes),
negative: negative.flatMap(({ mimeTypes }) => mimeTypes),
positive: this.#responses.positive.flatMap(({ mimeTypes }) => mimeTypes),
negative: this.#responses.negative.flatMap(({ mimeTypes }) => mimeTypes),
};
this.#schemas = { input: inputSchema, output: outputSchema };
}
Expand Down

0 comments on commit 4e84488

Please sign in to comment.