Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonapi-server

Package Overview
Dependencies
Maintainers
5
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonapi-server - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

documentation/metrics.md

2

CHANGELOG.md

@@ -0,1 +1,3 @@

- 2016-06-27 - v1.14.0
- 2016-06-27 - Enabled application metrics
- 2016-06-22 - v1.13.0

@@ -2,0 +4,0 @@ - 2016-06-22 - Fixed bug when setting singular relationships via deep urls

@@ -7,2 +7,3 @@ "use strict";

var path = require("path");
var debug = require("debug");

@@ -58,2 +59,6 @@ jsonApi.setConfig({

jsonApi.metrics.on("data", function(data) {
debug("metrics")(data);
});
// If we're using the example server for the test suite,

@@ -60,0 +65,0 @@ // wait for the tests to call .start();

@@ -19,4 +19,6 @@ /* @flow weak */

var url = require("url");
var metrics = require("./metrics.js");
jsonApi.Joi = ourJoi.Joi;
jsonApi.metrics = metrics.emitter;
jsonApi.MemoryHandler = require("./MemoryHandler");

@@ -23,0 +25,0 @@

24

lib/router.js

@@ -18,2 +18,3 @@ /* @flow weak */

var url = require("url");
var metrics = require("./metrics.js");

@@ -112,2 +113,4 @@

request.resourceConfig = resourceConfig;
res._request = request;
res._startDate = router._getPreciseTime();
router.authenticate(request, res, function() {

@@ -129,7 +132,7 @@ return callback(request, resourceConfig, res);

var errorWrapper = {
status: "401",
code: "UNAUTHORIZED",
title: "Authentication Failed",
detail: err || "You are not authorised to access this resource."
};
status: "401",
code: "UNAUTHORIZED",
title: "Authentication Failed",
detail: err || "You are not authorised to access this resource."
};
var payload = responseHelper.generateError(request, errorWrapper);

@@ -188,2 +191,4 @@ res.status(401).json(payload);

router.sendResponse = function(res, payload, httpCode) {
var timeDiff = router._getTimeDiff(router._getPreciseTime(), res._startDate);
metrics.processResponse(res._request, httpCode, payload, timeDiff);
res.status(httpCode).json(payload);

@@ -195,1 +200,10 @@ };

};
router._getTimeDiff = function(a, b) {
return parseFloat((a - b).toFixed(2));
};
router._getPreciseTime = function() {
var parts = process.hrtime();
return (((parts[0]*1000)+(parts[1]/1000000))%10000).toFixed(2);
};
{
"name": "jsonapi-server",
"version": "1.13.0",
"version": "1.14.0",
"description": "A config driven NodeJS framework implementing json:api",

@@ -5,0 +5,0 @@ "keywords": [

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