deployment API usage complete
This commit is contained in:
parent
75fda94588
commit
3f81757faa
|
@ -55,7 +55,8 @@ exports.authenticate = async ctx => {
|
||||||
}
|
}
|
||||||
// if in cloud add the user api key
|
// if in cloud add the user api key
|
||||||
if (environment.CLOUD) {
|
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, {
|
const token = jwt.sign(payload, ctx.config.jwtSecret, {
|
||||||
|
|
|
@ -45,7 +45,7 @@ module.exports = async (ctx, next) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jwtPayload = jwt.verify(appToken, ctx.config.jwtSecret)
|
const jwtPayload = jwt.verify(appToken, ctx.config.jwtSecret)
|
||||||
|
ctx.apiKey = jwtPayload.apiKey
|
||||||
ctx.user = {
|
ctx.user = {
|
||||||
...jwtPayload,
|
...jwtPayload,
|
||||||
accessLevel: await getAccessLevel(
|
accessLevel: await getAccessLevel(
|
||||||
|
|
|
@ -22,7 +22,7 @@ function buildUpdateParams(key, property, usage) {
|
||||||
return {
|
return {
|
||||||
primary: key,
|
primary: key,
|
||||||
condition:
|
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",
|
expression: "ADD #quota.#prop :usage",
|
||||||
names: {
|
names: {
|
||||||
"#quota": "usageQuota",
|
"#quota": "usageQuota",
|
||||||
|
@ -95,6 +95,6 @@ exports.update = async (apiKey, property, usage) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw "Resource limits have been reached"
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue