mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
docs
This commit is contained in:
@@ -4,12 +4,7 @@ function normalizeJambones(logger, obj) {
|
||||
const document = [];
|
||||
for (const tdata of obj) {
|
||||
if (typeof tdata !== 'object') throw new Error('invalid JSON: jambones docs must be array of objects');
|
||||
if (Object.keys(tdata).length === 1) {
|
||||
// {'say': {..}}
|
||||
logger.debug(`pushing ${JSON.stringify(tdata)}`);
|
||||
document.push(tdata);
|
||||
}
|
||||
else if ('verb' in tdata) {
|
||||
if ('verb' in tdata) {
|
||||
// {verb: 'say', text: 'foo..bar'..}
|
||||
const name = tdata.verb;
|
||||
const o = {};
|
||||
@@ -20,6 +15,11 @@ function normalizeJambones(logger, obj) {
|
||||
o2[name] = o;
|
||||
document.push(o2);
|
||||
}
|
||||
else if (Object.keys(tdata).length === 1) {
|
||||
// {'say': {..}}
|
||||
logger.debug(`pushing ${JSON.stringify(tdata)}`);
|
||||
document.push(tdata);
|
||||
}
|
||||
else {
|
||||
logger.info(tdata, `invalid JSON: invalid verb form, numkeys ${Object.keys(tdata).length}`);
|
||||
throw new Error('invalid JSON: invalid verb form');
|
||||
|
||||
Reference in New Issue
Block a user