mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
Add schema validation to create-call req.body, validate app_json via verb-specifications (#488)
* Add schema for create-call, validate app_json via verb-specifications * trigger new build --------- Co-authored-by: Markus Frindt <m.frindt@cognigy.com>
This commit is contained in:
114
lib/http-routes/schemas/create-call.js
Normal file
114
lib/http-routes/schemas/create-call.js
Normal file
@@ -0,0 +1,114 @@
|
||||
const { checkSchema } = require('express-validator');
|
||||
|
||||
/**
|
||||
* @path api-server {{base_url}}/v1/Accounts/:account_sid/Calls
|
||||
* @see https://api.jambonz.org/#243a2edd-7999-41db-bd0d-08082bbab401
|
||||
*/
|
||||
const createCallSchema = checkSchema({
|
||||
application_sid: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
isLength: { options: { min: 36, max: 36 } },
|
||||
errorMessage: 'Invalid application_sid',
|
||||
},
|
||||
answerOnBridge: {
|
||||
isBoolean: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid answerOnBridge',
|
||||
},
|
||||
from: {
|
||||
errorMessage: 'Invalid from',
|
||||
isString: true,
|
||||
isLength: {
|
||||
options: { min: 1, max: 256 },
|
||||
},
|
||||
},
|
||||
fromHost: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid fromHost',
|
||||
},
|
||||
to: {
|
||||
errorMessage: 'Invalid to',
|
||||
isObject: true,
|
||||
},
|
||||
callerName: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid callerName',
|
||||
},
|
||||
amd: {
|
||||
isObject: true,
|
||||
optional: true,
|
||||
},
|
||||
tag: {
|
||||
isObject: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid tag',
|
||||
},
|
||||
'tag.*': {
|
||||
trim: true,
|
||||
escape: true,
|
||||
stripLow: true,
|
||||
},
|
||||
app_json: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid app_json',
|
||||
},
|
||||
account_sid: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid account_sid',
|
||||
isLength: { options: { min: 36, max: 36 } },
|
||||
},
|
||||
timeout: {
|
||||
isInt: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid timeout',
|
||||
},
|
||||
timeLimit: {
|
||||
isInt: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid timeLimit',
|
||||
},
|
||||
call_hook: {
|
||||
isObject: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid call_hook',
|
||||
},
|
||||
call_status_hook: {
|
||||
isObject: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid call_status_hook',
|
||||
},
|
||||
speech_synthesis_vendor: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid speech_synthesis_vendor',
|
||||
},
|
||||
speech_synthesis_language: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid speech_synthesis_language',
|
||||
},
|
||||
speech_synthesis_voice: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid speech_synthesis_voice',
|
||||
},
|
||||
speech_recognizer_vendor: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid speech_recognizer_vendor',
|
||||
},
|
||||
speech_recognizer_language: {
|
||||
isString: true,
|
||||
optional: true,
|
||||
errorMessage: 'Invalid speech_recognizer_language',
|
||||
}
|
||||
}, ['body']);
|
||||
|
||||
module.exports = {
|
||||
createCallSchema
|
||||
};
|
||||
Reference in New Issue
Block a user