Interface IGetApiPropsActionContext<TResponse>

Context for a GetApiPropsAction action.

interface IGetApiPropsActionContext<TResponse> {
    request: NextApiRequest;
    response: NextApiResponse<TResponse>;
    sendConflict: ((message?) => void);
    sendData: ((data, code?) => void);
    sendForbidden: (() => void);
    sendList: ((items, code?) => void);
    sendNoContent: (() => void);
    sendNotFound: ((message) => void);
    sendValidationError: ((validationError) => void);
}

Type Parameters

  • TResponse = any

Properties

request: NextApiRequest

The request context.

response: NextApiResponse<TResponse>

The response context.

sendConflict: ((message?) => void)

Sends a standarized API 409 response.

Type declaration

    • (message?): void
    • Parameters

      • Optional message: string

        The custom message. Default: 'Conflict'

      Returns void

sendData: ((data, code?) => void)

Sends data on a standarized way.

Type declaration

    • (data, code?): void
    • Parameters

      • data: any

        The data to send.

      • Optional code: number

        The custom response status code.

      Returns void

sendForbidden: (() => void)

Sends a standarized API response for a forbidden resource.

Type declaration

    • (): void
    • Returns void

sendList: ((items, code?) => void)

Sends an standarized API response for a list.

Type declaration

    • (items, code?): void
    • Parameters

      • items: List<any>

        The items to send.

      • Optional code: number

        The custom response status code.

      Returns void

sendNoContent: (() => void)

Sends a 204 response.

Type declaration

    • (): void
    • Returns void

sendNotFound: ((message) => void)

Sends a standarized API 404 response.

Type declaration

    • (message): void
    • Parameters

      • message: string

        The custom message. Default: 'Not Found'

      Returns void

sendValidationError: ((validationError) => void)

Sends an API response for a body validation error.

Type declaration

    • (validationError): void
    • Parameters

      • validationError: ValidationError

        The error information.

      Returns void

Generated using TypeDoc