deployment API usage complete
This commit is contained in:
parent
4ec6fc4a52
commit
64b378364a
|
@ -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, {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue