serverless-global-authorizer
Version:
Serverless framework plugin which allows to configure API Gateway authorizer globally and applies it for all http/httpApi lambda function events
47 lines • 1.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineServerlessSchema = void 0;
const defineCustomPropertiesSchema = (serverless) => {
serverless.configSchemaHandler.defineCustomProperties({
type: 'object',
properties: {
globalAuthorizer: {
type: 'object',
additionalProperties: false,
properties: {
restApi: {
type: 'object',
additionalProperties: false,
properties: {
authorizer: { anyOf: [{ type: 'object' }, { type: 'string' }] },
},
required: ['authorizer'],
},
httpApi: {
type: 'object',
additionalProperties: false,
properties: {
authorizer: { anyOf: [{ type: 'object' }, { type: 'string' }] },
},
required: ['authorizer'],
},
},
},
},
});
};
const defineFunctionEventPropertiesSchema = (serverless) => {
const eventPropertiesSchema = {
properties: {
globalAuthorizerEnabled: { type: 'boolean' },
},
};
serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'http', eventPropertiesSchema);
serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'httpApi', eventPropertiesSchema);
};
const defineServerlessSchema = (serverless) => {
defineCustomPropertiesSchema(serverless);
defineFunctionEventPropertiesSchema(serverless);
};
exports.defineServerlessSchema = defineServerlessSchema;
//# sourceMappingURL=define-serverless-schema.js.map