New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@oddnetworks/oddworks

Package Overview
Dependencies
Maintainers
4
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oddnetworks/oddworks - npm Package Compare versions

Comparing version 3.4.3 to 3.5.0

10

CHANGELOG.md
# Changelog
## 3.5.0 Unstable
- Return [401 if channel/platform not active](https://github.com/oddnetworks/oddworks/pull/115)
- Properly return [405 instead of 403](https://github.com/oddnetworks/oddworks/pull/116) on bad method access.
- [Remove appending port to JSON API links](https://github.com/oddnetworks/oddworks/pull/117) in production environments.
- [JSON API compliant error objects](https://github.com/oddnetworks/oddworks/pull/120).
## 3.4.1 Unstable
- Correct JSON API error responses
## 3.4.0 Unstable

@@ -4,0 +14,0 @@

11

lib/middleware/error-handler.js

@@ -5,2 +5,4 @@ 'use strict';

const DEFAULT_TITLE = 'Internal Server Error';
// options.handler - Function

@@ -24,5 +26,10 @@ module.exports = function (options) {

return {
id: error.id,
links: error.links,
status: output.statusCode ? output.statusCode.toString() : '500',
title: output.payload ? output.payload.error : error.name,
detail: output.payload ? output.payload.message : (error.message || error.toString())
code: error.code,
title: output.payload ? output.payload.error : (error.name || DEFAULT_TITLE),
detail: output.payload ? output.payload.message : error.message,
source: error.source,
meta: error.meta
};

@@ -29,0 +36,0 @@ }

'use strict';
const _ = require('lodash');
module.exports = function (options) {
options = options || {};
options = options || {surrogateKey: false};

@@ -15,4 +17,45 @@ const header = [

res.set('Cache-Control', header);
if (options.surrogateKey) {
res.set('Surrogate-Key', composeSurrogateKey(req, res));
}
next();
};
};
function composeSurrogateKey(req, res) {
const channel = req.identity.channel.id;
const platform = req.identity.platform.id;
let surrogateKey = [
channel,
platform,
`${channel}:${platform}`
];
if (Array.isArray(res.body)) {
const ids = [];
const types = [];
_.each(res.body, item => {
ids.push(`${channel}:${item.id}`, `${channel}:${platform}:${item.id}`, item.id);
types.push(item.type);
});
surrogateKey = surrogateKey.concat(ids);
surrogateKey = surrogateKey.concat(
_(types)
.uniq()
.map(type => {
return [`${channel}:${type}`, `${channel}:${platform}:${type}`, type];
})
.flatten()
.value()
);
} else {
surrogateKey = surrogateKey.concat([`${channel}:${res.body.type}`, `${channel}:${platform}:${res.body.type}`, res.body.type]);
surrogateKey = surrogateKey.concat([`${channel}:${res.body.id}`, `${channel}:${platform}:${res.body.id}`, res.body.id]);
}
return surrogateKey.join(' ');
}

4

package.json
{
"name": "@oddnetworks/oddworks",
"version": "3.4.3",
"version": "3.5.0",
"description": "An extensible media platform for OTT devices.",

@@ -40,2 +40,4 @@ "main": "./lib/oddworks.js",

"jasmine": "~2.4.0",
"mock-express-request": "~0.1.0",
"mock-express-response": "~0.1.0",
"nsp": "~2.4.0",

@@ -42,0 +44,0 @@ "xo": "~0.15.0"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc