astro-ghostcms/.pnpm-store/v3/files/db/76909b1e7b37229aef8bdc3a788...

26 lines
682 B
Plaintext

import { Pipeline } from "../pipeline.js";
class EndpointNotFoundError extends Error {
originalResponse;
constructor(originalResponse) {
super();
this.originalResponse = originalResponse;
}
}
class SSRRoutePipeline extends Pipeline {
constructor(env) {
super(env);
this.setEndpointHandler(this.#ssrEndpointHandler);
}
// This function is responsible for handling the result coming from an endpoint.
async #ssrEndpointHandler(request, response) {
if (response.headers.get("X-Astro-Response") === "Not-Found") {
throw new EndpointNotFoundError(response);
}
return response;
}
}
export {
EndpointNotFoundError,
SSRRoutePipeline
};