Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
760 B

const builderDB = require("../../db/builder")
exports.fetch = async function(ctx) {
try {
const mainDoc = await builderDB.getBuilderMainDoc()
ctx.body = mainDoc.apiKeys ? mainDoc.apiKeys : {}
} catch (err) {
/* istanbul ignore next */
ctx.throw(400, err)
}
}
exports.update = async function(ctx) {
const key = ctx.params.key
const value = ctx.request.body.value
try {
const mainDoc = await builderDB.getBuilderMainDoc()
if (mainDoc.apiKeys == null) {
mainDoc.apiKeys = {}
}
mainDoc.apiKeys[key] = value
const resp = await builderDB.setBuilderMainDoc(mainDoc)
ctx.body = {
_id: resp.id,
_rev: resp.rev,
}
} catch (err) {
/* istanbul ignore next */
ctx.throw(400, err)
}
}