jsonapi-server
Advanced tools
Comparing version 1.13.0 to 1.14.0
@@ -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 @@ |
@@ -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": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
247133
83
5737
1
97