1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00

deployment API usage complete

This commit is contained in:
Martin McKeaveney 2020-10-09 21:42:20 +01:00
parent 75fda94588
commit 3f81757faa
3 changed files with 5 additions and 4 deletions

View file

@ -55,7 +55,8 @@ exports.authenticate = async ctx => {
}
// if in cloud add the user api key
if (environment.CLOUD) {
payload.apiKey = getAPIKey(ctx.user.appId)
const { apiKey } = await getAPIKey(ctx.user.appId)
payload.apiKey = apiKey
}
const token = jwt.sign(payload, ctx.config.jwtSecret, {

View file

@ -45,7 +45,7 @@ module.exports = async (ctx, next) => {
try {
const jwtPayload = jwt.verify(appToken, ctx.config.jwtSecret)
ctx.apiKey = jwtPayload.apiKey
ctx.user = {
...jwtPayload,
accessLevel: await getAccessLevel(

View file

@ -22,7 +22,7 @@ function buildUpdateParams(key, property, usage) {
return {
primary: key,
condition:
"#quota.#prop < #limits.#prop AND #quotaReset > :now AND attribute_exists(#quota) AND attribute_exists(#limits)",
"attribute_exists(#quota) AND attribute_exists(#limits) AND #quota.#prop < #limits.#prop AND #quotaReset > :now",
expression: "ADD #quota.#prop :usage",
names: {
"#quota": "usageQuota",
@ -95,6 +95,6 @@ exports.update = async (apiKey, property, usage) => {
return
}
}
throw "Resource limits have been reached"
throw err
}
}