mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
[ci] format
This commit is contained in:
parent
c12666166d
commit
1fc9b6062a
2 changed files with 7 additions and 6 deletions
|
@ -792,11 +792,11 @@ export const MiddlewareNotAResponse = {
|
|||
* @docs
|
||||
* @description
|
||||
* Thrown when an endpoint does not return anything or returns an object that is not a `Response` object.
|
||||
*
|
||||
*
|
||||
* An endpoint must return either a `Response`, or a `Promise` that resolves with a `Response`. For example:
|
||||
* ```ts
|
||||
* import type { APIContext } from 'astro';
|
||||
*
|
||||
*
|
||||
* export async function GET({ request, url, cookies }: APIContext): Promise<Response> {
|
||||
* return Response.json({
|
||||
* success: true,
|
||||
|
@ -808,7 +808,8 @@ export const MiddlewareNotAResponse = {
|
|||
export const EndpointDidNotReturnAResponse = {
|
||||
name: 'EndpointDidNotReturnAResponse',
|
||||
title: 'The endpoint did not return a `Response`.',
|
||||
message: 'An endpoint must return either a `Response`, or a `Promise` that resolves with a `Response`.',
|
||||
message:
|
||||
'An endpoint must return either a `Response`, or a `Promise` that resolves with a `Response`.',
|
||||
} satisfies ErrorData;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { bold } from 'kleur/colors';
|
||||
import type { APIContext, EndpointHandler } from '../../@types/astro.js';
|
||||
import { REROUTABLE_STATUS_CODES, REROUTE_DIRECTIVE_HEADER } from '../../core/constants.js';
|
||||
import type { Logger } from '../../core/logger/core.js';
|
||||
import { AstroError } from '../../core/errors/errors.js';
|
||||
import { EndpointDidNotReturnAResponse } from '../../core/errors/errors-data.js';
|
||||
import { AstroError } from '../../core/errors/errors.js';
|
||||
import type { Logger } from '../../core/logger/core.js';
|
||||
|
||||
/** Renders an endpoint request to completion, returning the body. */
|
||||
export async function renderEndpoint(
|
||||
|
@ -53,7 +53,7 @@ export async function renderEndpoint(
|
|||
const response = await handler.call(mod, context);
|
||||
|
||||
if (!response || response instanceof Response === false) {
|
||||
throw new AstroError(EndpointDidNotReturnAResponse)
|
||||
throw new AstroError(EndpointDidNotReturnAResponse);
|
||||
}
|
||||
|
||||
// Endpoints explicitly returning 404 or 500 response status should
|
||||
|
|
Loading…
Add table
Reference in a new issue