hitting deployment success endpoint

This commit is contained in:
Martin McKeaveney 2020-10-08 10:56:32 +01:00
parent 3dca82a5ff
commit 39d2adb9e3
2 changed files with 27 additions and 1 deletions

View File

@ -21,6 +21,27 @@ async function invalidateCDN(cfDistribution, appId) {
.promise()
}
exports.updateDeploymentQuota = async function(quota) {
const response = await fetch(
`${process.env.DEPLOYMENT_CREDENTIALS_URL}/deploy/success`,
{
method: "POST",
body: JSON.stringify({
apiKey: process.env.BUDIBASE_API_KEY,
quota,
}),
}
)
if (response.status !== 200) {
throw new Error(`Error updating deployment quota for app`)
}
const json = await response.json()
return json
}
/**
* Verifies the users API key and
* Verifies that the deployment fits within the quota of the user,

View File

@ -3,7 +3,7 @@ const PouchDB = require("../../../db")
const {
uploadAppAssets,
verifyDeployment,
determineDeploymentAllowed,
updateDeploymentQuota,
} = require("./aws")
const { getRecordParams } = require("../../db/utils")
@ -85,6 +85,11 @@ exports.deployApp = async function(ctx) {
credentials: credentials.couchDbCreds,
})
const deployedInstanceQuota = await getCurrentInstanceQuota(
ctx.user.instanceId
)
updateDeploymentQuota(deployedInstanceQuota)
ctx.body = {
status: "SUCCESS",
completed: Date.now(),