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.
 
 
 
 
 
 

31 lines
792 B

const { create, destroy } = require("../../db/clientDb")
const env = require("../../environment")
exports.getClientId = async function(ctx) {
ctx.body = env.CLIENT_ID
}
exports.create = async function(ctx) {
const clientId = getClientId(ctx)
await create(clientId)
ctx.status = 200
ctx.message = `Client Database ${clientId} successfully provisioned.`
}
exports.destroy = async function(ctx) {
const clientId = getClientId(ctx)
await destroy(clientId)
ctx.status = 200
ctx.message = `Client Database ${clientId} successfully deleted.`
}
const getClientId = ctx => {
const clientId =
(ctx.query && ctx.query.clientId) ||
(ctx.body && ctx.body.clientId) ||
env.CLIENT_ID
if (!clientId) {
ctx.throw(400, "ClientId not supplied")
}
return clientId
}