0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-04-07 23:01:25 -05:00

refactor(core): log cloudflare error ()

This commit is contained in:
Gao Sun 2024-02-09 00:42:07 +08:00 committed by GitHub
parent 39b963daf3
commit 40eeea8cc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions
packages/core/src
routes/applications
utils/cloudflare

View file

@ -129,7 +129,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
koaGuard({
body: applicationCreateGuard,
response: Applications.guard,
status: [200, 400, 422],
status: [200, 400, 422, 500],
}),
async (ctx, next) => {
const { oidcClientMetadata, protectedAppMetadata, ...rest } = ctx.guard.body;

View file

@ -4,6 +4,7 @@ import { type Response } from 'got';
import { type ZodType } from 'zod';
import assertThat from '../assert-that.js';
import { consoleLog } from '../console.js';
import { type HandleResponse, cloudflareResponseGuard } from './types.js';
@ -18,6 +19,7 @@ const parseCloudflareResponse = (body: string) => {
export const buildHandleResponse = (handleError: (statusCode: number) => never) => {
const handleResponse: HandleResponse = <T>(response: Response<string>, guard?: ZodType<T>) => {
if (!response.ok) {
consoleLog.error('Cloudflare API error', response.statusCode, response.body);
handleError(response.statusCode);
}