hitting deployment success endpoint
This commit is contained in:
parent
3dca82a5ff
commit
39d2adb9e3
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue