@oddnetworks/oddworks
Advanced tools
Comparing version 3.9.3 to 3.9.4
@@ -128,4 +128,13 @@ 'use strict'; | ||
let link = `${baseUrl}`; | ||
if (BASE_PREFIX && req.originalUrl.indexOf(BASE_PREFIX) === 0) { | ||
// create a suffix that does not have the BASE_PREFIX in it | ||
const suffix = req.originalUrl.substr(BASE_PREFIX.length, (req.originalUrl.length - BASE_PREFIX.length)); | ||
link += suffix; | ||
} else { | ||
link += `${req.originalUrl}`; | ||
} | ||
res.body.links = { | ||
self: `${baseUrl}${req.originalUrl}` | ||
self: link | ||
}; | ||
@@ -132,0 +141,0 @@ } else { |
'use strict'; | ||
const _ = require('lodash'); | ||
const Boom = require('boom'); | ||
@@ -38,3 +39,8 @@ const controller = require('../../../controllers/controller'); | ||
const payload = req.body; | ||
const channel = payload.channel || (req.identity.channel || {}).id; | ||
if (type !== 'channel' && !channel) { | ||
return next(Boom.badData('"channel" is required')); | ||
} | ||
const args = { | ||
@@ -52,9 +58,12 @@ channel: req.identity.channel, | ||
resource = _.merge({}, resource, payload); | ||
resource.channel = args.channel; | ||
resource.channel = channel; | ||
resource.type = type; | ||
resource.id = args.id; | ||
this.bus.sendCommand({role: 'catalog', cmd: 'setItem'}, resource); | ||
res.body = {}; | ||
return this.bus.sendCommand({role: 'catalog', cmd: 'setItem'}, resource); | ||
}) | ||
.then(resource => { | ||
res.body = resource; | ||
res.status(200); | ||
return next(); | ||
}) | ||
@@ -64,2 +73,29 @@ .catch(next); | ||
delete(req, res, next) { | ||
const type = this.type; | ||
const payload = req.body; | ||
const channel = payload.channel || (req.identity.channel || {}).id; | ||
if (type !== 'channel' && !channel) { | ||
return next(Boom.badData('"channel" is required')); | ||
} | ||
const args = { | ||
type, | ||
id: req.params.id | ||
}; | ||
if (type !== 'channel') { | ||
args.channel = channel; | ||
} | ||
this.bus.sendCommand({role: 'catalog', cmd: 'removeItem', type}, args) | ||
.then(() => { | ||
res.body = {}; | ||
res.status(202); | ||
return next(); | ||
}) | ||
.catch(next); | ||
} | ||
static create(spec) { | ||
@@ -66,0 +102,0 @@ if (!spec.bus || !_.isObject(spec.bus)) { |
@@ -80,20 +80,21 @@ 'use strict'; | ||
return this.bus | ||
.query({role: 'catalog', cmd: 'fetchItemSpec'}, args) | ||
.then(resource => { | ||
if (!resource) { | ||
return next(Boom.notFound(`cannot find ${type} ${id}`)); | ||
} | ||
return this.bus.query({role: 'catalog', cmd: 'fetchItemSpec'}, args); | ||
}) | ||
.then(resource => { | ||
if (!resource) { | ||
return next(Boom.notFound(`cannot find ${type} ${id}`)); | ||
} | ||
resource = _.merge({}, resource, payload); | ||
resource.channel = channel.id; | ||
resource.type = this.type; | ||
resource.id = id; | ||
resource = _.merge({}, resource, payload); | ||
resource.channel = channel.id; | ||
resource.type = this.type; | ||
resource.id = id; | ||
this.bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, resource); | ||
res.body = {}; | ||
res.status(200); | ||
return next(); | ||
}); | ||
return this.bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, resource); | ||
}) | ||
.then(resource => { | ||
res.body = resource; | ||
res.status(200); | ||
return next(); | ||
}) | ||
.catch(next); | ||
@@ -100,0 +101,0 @@ } |
@@ -118,3 +118,3 @@ 'use strict'; | ||
const specTypes = options.specTypes; | ||
const router = options.router || express.Router(); // eslint-disable-line | ||
const router = options.router || express.Router(); // eslint-disable-line babel/new-cap | ||
@@ -121,0 +121,0 @@ types.forEach(type => { |
@@ -34,2 +34,6 @@ 'use strict'; | ||
.then(resource => { | ||
if (!resource) { | ||
return next(Boom.notFound('resource not found')); | ||
} | ||
res.body = resource; | ||
@@ -74,4 +78,6 @@ res.status(200); | ||
this.bus.sendCommand({role: 'store', cmd: 'set', type}, resource); | ||
res.body = {}; | ||
return this.bus.sendCommand({role: 'store', cmd: 'set', type}, resource); | ||
}) | ||
.then(resource => { | ||
res.body = resource; | ||
res.status(200); | ||
@@ -83,2 +89,29 @@ return next(); | ||
delete(req, res, next) { | ||
const type = this.type; | ||
const payload = req.body; | ||
const channel = payload.channel || (req.identity.channel || {}).id; | ||
if (type !== 'channel' && !channel) { | ||
return next(Boom.badData('"channel" is required')); | ||
} | ||
const args = { | ||
type, | ||
id: req.params.id | ||
}; | ||
if (type !== 'channel') { | ||
args.channel = channel; | ||
} | ||
this.bus.sendCommand({role: 'store', cmd: 'remove', type}, args) | ||
.then(() => { | ||
res.body = {}; | ||
res.status(202); | ||
return next(); | ||
}) | ||
.catch(next); | ||
} | ||
static create(spec) { | ||
@@ -85,0 +118,0 @@ if (!spec.bus || !_.isObject(spec.bus)) { |
@@ -64,3 +64,3 @@ 'use strict'; | ||
const types = options.types; | ||
const router = options.router || express.Router(); // eslint-disable-line | ||
const router = options.router || express.Router(); // eslint-disable-line babel/new-cap | ||
@@ -67,0 +67,0 @@ types.forEach(type => { |
{ | ||
"name": "@oddnetworks/oddworks", | ||
"version": "3.9.3", | ||
"version": "3.9.4", | ||
"description": "An extensible media platform for OTT devices.", | ||
@@ -24,3 +24,3 @@ "main": "./lib/oddworks.js", | ||
"body-parser": "~1.15.0", | ||
"boom": "~3.2.0", | ||
"boom": "~4.0.0", | ||
"debug": "~2.2.0", | ||
@@ -30,17 +30,18 @@ "dynamodb-marshaler": "~2.0.0", | ||
"header-parser": "~1.0.0", | ||
"jsonwebtoken": "~7.0.0", | ||
"lodash": "~3.10.0", | ||
"jsonwebtoken": "~7.1.0", | ||
"lodash": "^3.0.0", | ||
"node-uuid": "~1.4.0", | ||
"oddcast": "~2.0.0", | ||
"oddcast": "~2.1.0", | ||
"redis-search": "~0.0.1" | ||
}, | ||
"devDependencies": { | ||
"aws-sdk": "~2.4.0", | ||
"aws-sdk": "~2.5.0", | ||
"dynalite": "~1.0.0", | ||
"fakeredis": "~1.0.0", | ||
"jasmine": "~2.4.0", | ||
"jsonschema": "^1.1.0", | ||
"mock-express-request": "~0.1.0", | ||
"mock-express-response": "~0.1.0", | ||
"nsp": "~2.4.0", | ||
"xo": "~0.15.0" | ||
"nsp": "~2.6.0", | ||
"xo": "~0.16.0" | ||
}, | ||
@@ -47,0 +48,0 @@ "xo": { |
143082
3192
9
54
+ Addedboom@4.0.0(transitive)
+ Addedjsonwebtoken@7.1.10(transitive)
+ Addedlodash.once@4.1.1(transitive)
+ Addedoddcast@2.1.0(transitive)
- Removedbluebird@3.3.5(transitive)
- Removedboom@3.2.2(transitive)
- Removedjsonwebtoken@7.0.1(transitive)
- Removedoddcast@2.0.0(transitive)
Updatedboom@~4.0.0
Updatedjsonwebtoken@~7.1.0
Updatedlodash@^3.0.0
Updatedoddcast@~2.1.0