Release 202505311149
This commit is contained in:
@@ -24,7 +24,7 @@ export const apiServiceActions = {
|
|||||||
.optional(),
|
.optional(),
|
||||||
url: zodUrlOptionalProtocol.optional(),
|
url: zodUrlOptionalProtocol.optional(),
|
||||||
}),
|
}),
|
||||||
handler: async (input) => {
|
handler: async (input, context) => {
|
||||||
if (!input.id && !input.slug && !input.url) {
|
if (!input.id && !input.slug && !input.url) {
|
||||||
throw new ActionError({
|
throw new ActionError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
@@ -122,7 +122,7 @@ export const apiServiceActions = {
|
|||||||
(url) => url + (service.referral ?? '')
|
(url) => url + (service.referral ?? '')
|
||||||
),
|
),
|
||||||
tosUrls: service.tosUrls,
|
tosUrls: service.tosUrls,
|
||||||
kycnotmeUrl: `https://kycnot.me/service/${service.slug}`,
|
kycnotmeUrl: new URL(`/service/${service.slug}`, context.url).href,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -13,15 +13,38 @@ export async function makeAdminApiCallInfo<T extends Misc.JSON.Object>({
|
|||||||
}) {
|
}) {
|
||||||
const fullPath = new URL(`/api/v1${path}`, baseUrl).href
|
const fullPath = new URL(`/api/v1${path}`, baseUrl).href
|
||||||
|
|
||||||
|
const fetchProsmise = fetch(fullPath, {
|
||||||
|
method,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(input),
|
||||||
|
}).then((res) => {
|
||||||
|
try {
|
||||||
|
return res.json() as Promise<Misc.JSON.Value>
|
||||||
|
} catch (errJson: unknown) {
|
||||||
|
console.error(errJson)
|
||||||
|
|
||||||
|
try {
|
||||||
|
return res.text()
|
||||||
|
} catch (errText: unknown) {
|
||||||
|
console.error(errText)
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let output: Misc.JSON.Value = ''
|
||||||
|
try {
|
||||||
|
output = await fetchProsmise
|
||||||
|
} catch (err: unknown) {
|
||||||
|
console.error(err)
|
||||||
|
output = err instanceof Error ? err.message : String(err)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
method,
|
method,
|
||||||
path,
|
path,
|
||||||
fullPath,
|
fullPath,
|
||||||
input,
|
input,
|
||||||
output: await fetch(fullPath, {
|
output,
|
||||||
method,
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(input),
|
|
||||||
}).then((res) => res.json() as Promise<Misc.JSON.Value>),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { Icon } from 'astro-icon/components'
|
import { Icon } from 'astro-icon/components'
|
||||||
import { Markdown } from 'astro-remote'
|
import { Markdown } from 'astro-remote'
|
||||||
import { actions, isInputError } from 'astro:actions'
|
import { actions, isInputError } from 'astro:actions'
|
||||||
|
import { Code } from 'astro:components'
|
||||||
import { orderBy } from 'lodash-es'
|
import { orderBy } from 'lodash-es'
|
||||||
|
|
||||||
import BadgeSmall from '../../../../components/BadgeSmall.astro'
|
import BadgeSmall from '../../../../components/BadgeSmall.astro'
|
||||||
@@ -1121,16 +1122,10 @@ const apiCalls = await Astro.locals.banners.try(
|
|||||||
apiCalls.map((call) => (
|
apiCalls.map((call) => (
|
||||||
<FormSubSection title={`${call.method} ${call.path}`}>
|
<FormSubSection title={`${call.method} ${call.path}`}>
|
||||||
<p class="text-day-400 text-sm">Input:</p>
|
<p class="text-day-400 text-sm">Input:</p>
|
||||||
<pre
|
<Code code={JSON.stringify(call.input, null, 2)} lang="json" class="rounded-lg p-4 text-xs" />
|
||||||
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>
|
<p class="text-day-400 text-sm">Output:</p>
|
||||||
<pre
|
<Code code={JSON.stringify(call.output, null, 2)} lang="json" class="rounded-lg p-4 text-xs" />
|
||||||
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>
|
</FormSubSection>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user