Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/apiGateway/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const customErrorBuilder = (type, message) => (errors) => {
return errors
}

const Joi = require('@hapi/joi')
const Joi = require('joi')

const path = Joi.string().required()

Expand Down Expand Up @@ -327,8 +327,11 @@ const schema = Joi.array()
let message = ''
if (proxiesSchemas[proxyKey]) {
// e.g. value is { kinesis: { path: '/kinesis', method: 'xxxx' } }
const { error: proxyError } = Joi.validate(error.context.value, proxiesSchemas[proxyKey])
message = proxyError.message
Joi.validate(error.context.value, proxiesSchemas[proxyKey], {}, (err) => {
if (err) {
message = err.message
}
})
} else {
// e.g. value is { xxxxx: { path: '/kinesis', method: 'post' } }
message = `Invalid APIG proxy "${proxyKey}". This plugin supported Proxies are: ${allowedProxies.join(
Expand Down
11 changes: 6 additions & 5 deletions lib/apiGateway/validate.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
'use strict'
const NOT_FOUND = -1
const _ = require('lodash')
const Joi = require('@hapi/joi')
const Joi = require('joi')
const schema = require('./schema')

module.exports = {
validateServiceProxies() {
const proxies = this.getAllServiceProxies()

const { error } = Joi.validate(proxies, schema)
if (error) {
throw new this.serverless.classes.Error(error.message)
}
Joi.validate(proxies, schema, {}, (err) => {
if (err) {
throw new this.serverless.classes.Error(err.message)
}
})

const corsPreflight = {}

Expand Down
Loading