hitting deployment success endpoint

This commit is contained in:
Martin McKeaveney 2020-10-08 10:56:32 +01:00
parent a482d0a23e
commit 212a24348a
2 changed files with 27 additions and 1 deletions

View File

@ -21,6 +21,27 @@ async function invalidateCDN(cfDistribution, appId) {
.promise() .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 the users API key and
* Verifies that the deployment fits within the quota of the user, * Verifies that the deployment fits within the quota of the user,

View File

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