Browse Source

hitting deployment success endpoint

pull/4023/head
Martin McKeaveney 6 years ago
parent
commit
39d2adb9e3
  1. 21
      packages/server/src/api/controllers/deploy/aws.js
  2. 7
      packages/server/src/api/controllers/deploy/index.js

21
packages/server/src/api/controllers/deploy/aws.js

@ -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,

7
packages/server/src/api/controllers/deploy/index.js

@ -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…
Cancel
Save