forked from tsai/budibase
committed by
GitHub
2 changed files with 28 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||||
|
const { Headers } = require("@budibase/backend-core/constants") |
||||
|
const { getAppId } = require("@budibase/backend-core/utils") |
||||
|
|
||||
|
module.exports = function ({ requiresAppId } = {}) { |
||||
|
return async (ctx, next) => { |
||||
|
const appId = getAppId(ctx) |
||||
|
if (requiresAppId && !appId) { |
||||
|
ctx.throw( |
||||
|
400, |
||||
|
`Invalid app ID provided, please check the ${Headers.APP_ID} header.` |
||||
|
) |
||||
|
} |
||||
|
if (!ctx.headers[Headers.API_KEY]) { |
||||
|
ctx.throw( |
||||
|
400, |
||||
|
`Invalid API key provided, please check the ${Headers.API_KEY} header.` |
||||
|
) |
||||
|
} |
||||
|
return next() |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue