PR comments.

This commit is contained in:
mike12345567 2024-02-22 17:37:03 +00:00
parent 2f6df51e2c
commit 5dd87265d2
1 changed files with 11 additions and 32 deletions

View File

@ -1,37 +1,16 @@
import { getDefinition, getDefinitions } from "../../integrations" import { getDefinition, getDefinitions } from "../../integrations"
import { BBContext } from "@budibase/types" import { SourceName, UserCtx } from "@budibase/types"
async function fetchDefinitions(ctx: BBContext) { export async function fetch(ctx: UserCtx) {
try {
const definitions = await getDefinitions() const definitions = await getDefinitions()
delete definitions.AIRTABLE delete definitions.AIRTABLE
ctx.status = 200
ctx.body = definitions ctx.body = definitions
return definitions
} catch (error) {
console.error("Error fetching definitions:", error)
ctx.status = 500
ctx.body = { error: "Internal server error" }
return {}
}
} }
export async function fetch(ctx: BBContext) { export async function find(ctx: UserCtx) {
await fetchDefinitions(ctx) const sourceType = ctx.params?.type
} if (sourceType === SourceName.AIRTABLE) {
ctx.throw(400, `Invalid source type - ${sourceType} is not supported.`)
export async function find(ctx: BBContext) {
const def = await getDefinition(ctx.params.type)
if (ctx.params.type in (await fetchDefinitions(ctx))) {
ctx.body = def
ctx.status = 200
} else {
ctx.status = 400
ctx.body = {
message: `Cannot find definition '${ctx.params.type}'`,
status: 400,
}
} }
ctx.body = await getDefinition(ctx.params.type)
} }