1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00
budibase/packages/worker/src/api/controllers/global/license.ts

31 lines
706 B
TypeScript
Raw Normal View History

import { licensing, quotas } from "@budibase/pro"
2022-03-10 10:16:22 +13:00
export const activate = async (ctx: any) => {
const { licenseKey } = ctx.request.body
if (!licenseKey) {
ctx.throw(400, "licenseKey is required")
}
await licensing.activateLicenseKey(licenseKey)
2022-03-10 10:16:22 +13:00
ctx.status = 200
}
export const refresh = async (ctx: any) => {
await licensing.cache.refresh()
2022-03-10 10:16:22 +13:00
ctx.status = 200
}
export const getInfo = async (ctx: any) => {
const licenseInfo = await licensing.getLicenseInfo()
2022-03-10 10:16:22 +13:00
if (licenseInfo) {
licenseInfo.licenseKey = "*"
ctx.body = licenseInfo
}
ctx.status = 200
}
2022-03-15 21:16:45 +13:00
export const getQuotaUsage = async (ctx: any) => {
const usage = await quotas.getQuotaUsage()
2022-03-15 21:16:45 +13:00
ctx.body = usage
}