mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-09 21:14:00 +00:00
feat: start using verb-specifications (#107)
* feat: start using verb-specifications * fix: verb specification v2 * fix vulnerabilities --------- Co-authored-by: Quan HL <quanluuhoang8@gmail.com> Co-authored-by: Dave Horton <daveh@beachdognet.com>
This commit is contained in:
co-authored by
Quan HL
Dave Horton
parent
5b48fc8a07
commit
4d48c6946c
@@ -6,7 +6,7 @@ const Webhook = require('../../models/webhook');
|
||||
const {promisePool} = require('../../db');
|
||||
const decorate = require('./decorate');
|
||||
const sysError = require('../error');
|
||||
const jambonzAppJsonValidator = require('../../utils/jambonz-app-json-validation');
|
||||
const { validate } = require('verb-specifications/jambonz-app-json-validation');
|
||||
const preconditions = {
|
||||
'add': validateAdd,
|
||||
'update': validateUpdate
|
||||
@@ -80,7 +80,11 @@ router.post('/', async(req, res) => {
|
||||
// validate app json if required
|
||||
if (obj['app_json']) {
|
||||
const app_json = JSON.parse(obj['app_json']);
|
||||
jambonzAppJsonValidator(logger, app_json);
|
||||
try {
|
||||
validate(logger, app_json);
|
||||
} catch (err) {
|
||||
throw new DbErrorBadRequest(err);
|
||||
}
|
||||
}
|
||||
|
||||
const uuid = await Application.make(obj);
|
||||
@@ -189,7 +193,11 @@ router.put('/:sid', async(req, res) => {
|
||||
// validate app json if required
|
||||
if (obj['app_json']) {
|
||||
const app_json = JSON.parse(obj['app_json']);
|
||||
jambonzAppJsonValidator(logger, app_json);
|
||||
try {
|
||||
validate(logger, app_json);
|
||||
} catch (err) {
|
||||
throw new DbErrorBadRequest(err);
|
||||
}
|
||||
}
|
||||
|
||||
const rowsAffected = await Application.update(sid, obj);
|
||||
|
||||
Reference in New Issue
Block a user