Release 202505311113
This commit is contained in:
@@ -114,7 +114,13 @@ export class ErrorBanners {
|
|||||||
return result
|
return result
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.handler(uiMessage)(error)
|
this.handler(uiMessage)(error)
|
||||||
return fallback as F
|
return fallback as F extends never[]
|
||||||
|
? T extends [infer _First, ...infer _Rest]
|
||||||
|
? []
|
||||||
|
: T extends unknown[]
|
||||||
|
? T[number][]
|
||||||
|
: F
|
||||||
|
: F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
web/src/lib/makeAdminApiCallInfo.ts
Normal file
27
web/src/lib/makeAdminApiCallInfo.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import type { Misc } from 'ts-toolbelt'
|
||||||
|
|
||||||
|
export async function makeAdminApiCallInfo<T extends Misc.JSON.Object>({
|
||||||
|
method,
|
||||||
|
path,
|
||||||
|
input,
|
||||||
|
baseUrl,
|
||||||
|
}: {
|
||||||
|
method: 'POST' | 'QUERY'
|
||||||
|
path: `/${string}`
|
||||||
|
input: T
|
||||||
|
baseUrl: URL | string
|
||||||
|
}) {
|
||||||
|
const fullPath = new URL(`/api/v1${path}`, baseUrl).href
|
||||||
|
|
||||||
|
return {
|
||||||
|
method,
|
||||||
|
path,
|
||||||
|
fullPath,
|
||||||
|
input,
|
||||||
|
output: await fetch(fullPath, {
|
||||||
|
method,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(input),
|
||||||
|
}).then((res) => res.json() as Promise<Misc.JSON.Value>),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
verificationStepStatuses,
|
verificationStepStatuses,
|
||||||
} from '../../../../constants/verificationStepStatus'
|
} from '../../../../constants/verificationStepStatus'
|
||||||
import BaseLayout from '../../../../layouts/BaseLayout.astro'
|
import BaseLayout from '../../../../layouts/BaseLayout.astro'
|
||||||
|
import { makeAdminApiCallInfo } from '../../../../lib/makeAdminApiCallInfo'
|
||||||
import { pluralize } from '../../../../lib/pluralize'
|
import { pluralize } from '../../../../lib/pluralize'
|
||||||
import { prisma } from '../../../../lib/prisma'
|
import { prisma } from '../../../../lib/prisma'
|
||||||
|
|
||||||
@@ -181,6 +182,20 @@ const [service, categories, attributes] = await Astro.locals.banners.tryMany([
|
|||||||
])
|
])
|
||||||
|
|
||||||
if (!service) return Astro.rewrite('/404')
|
if (!service) return Astro.rewrite('/404')
|
||||||
|
|
||||||
|
const apiCalls = await Astro.locals.banners.try(
|
||||||
|
'Error fetching api calls',
|
||||||
|
() =>
|
||||||
|
Promise.all([
|
||||||
|
makeAdminApiCallInfo({
|
||||||
|
method: 'QUERY',
|
||||||
|
path: '/service/get',
|
||||||
|
input: { slug: service.slug },
|
||||||
|
baseUrl: Astro.url,
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
[]
|
||||||
|
)
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout pageTitle={`Edit Service: ${service.name}`}>
|
<BaseLayout pageTitle={`Edit Service: ${service.name}`}>
|
||||||
@@ -1100,5 +1115,25 @@ if (!service) return Astro.rewrite('/404')
|
|||||||
</form>
|
</form>
|
||||||
</FormSubSection>
|
</FormSubSection>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
|
<FormSection title="API">
|
||||||
|
{
|
||||||
|
apiCalls.map((call) => (
|
||||||
|
<FormSubSection title={`${call.method} ${call.path}`}>
|
||||||
|
<p class="text-day-400 text-sm">Input:</p>
|
||||||
|
<pre
|
||||||
|
class="bg-night-800 border-night-500 text-day-300 overflow-x-auto rounded-md border p-3"
|
||||||
|
set:text={JSON.stringify(call.input, null, 2)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<p class="text-day-400 text-sm">Output:</p>
|
||||||
|
<pre
|
||||||
|
class="bg-night-800 border-night-500 text-day-300 overflow-x-auto rounded-md border p-3"
|
||||||
|
set:text={JSON.stringify(call.output, null, 2)}
|
||||||
|
/>
|
||||||
|
</FormSubSection>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user