yslow-data-rest-api
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -33,5 +33,5 @@ var express = require('express'); | ||
console.error(err.stack); | ||
res.json(status, { error: { message: err.message } }); | ||
res.json(status, { errors: [{ message: err.message }] }); | ||
}); | ||
module.exports = app; |
@@ -11,7 +11,7 @@ var service = require('yslow-data-service'); | ||
service.results.create(data, function (err, report) { | ||
service.results.create(data, function (err, result) { | ||
if (err) next(err); | ||
res.header('Location', '/results/' + report.id); | ||
res.send(201); | ||
res.header('Location', '/results/' + result.id); | ||
res.json(201, {results: [result]}); | ||
}); | ||
@@ -18,0 +18,0 @@ } |
@@ -19,3 +19,3 @@ var service = require('yslow-data-service'); | ||
res.json(results); | ||
res.json({results: results}); | ||
}); | ||
@@ -34,5 +34,11 @@ }, | ||
service.results.latest(options, function (err, result) { | ||
var results = []; | ||
if (err) next(err); | ||
res.json(result); | ||
if (result) { | ||
results.push(result); | ||
} | ||
res.json({results: results}); | ||
}); | ||
@@ -55,3 +61,3 @@ }, | ||
res.json(result); | ||
res.json({results: [result]}); | ||
}); | ||
@@ -58,0 +64,0 @@ }, |
@@ -12,3 +12,3 @@ var service = require('yslow-data-service'); | ||
res.json(urls); | ||
res.json({urls: urls}); | ||
}); | ||
@@ -15,0 +15,0 @@ } |
{ | ||
"name": "yslow-data-rest-api", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "REST API for storing YSlow performance data", | ||
@@ -29,4 +29,4 @@ "main": "index.js", | ||
"chalk": "~0.4.0", | ||
"yslow-data-service": "~0.1.0" | ||
"yslow-data-service": "~0.1.1" | ||
} | ||
} |
146
README.md
@@ -35,17 +35,19 @@ # yslow-data-rest-api | ||
```json | ||
[ | ||
{ | ||
"id": "52b887a7e486520836000003", | ||
"timestamp": "2013-12-23T18:57:43.216Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": 510283, | ||
"o": 76, | ||
"u": "http://www.bbc.co.uk/", | ||
"r": 87, | ||
"i": "ydefault", | ||
"lt": 1706 | ||
{ | ||
"results": [ | ||
{ | ||
"id": "52b887a7e486520836000003", | ||
"timestamp": "2013-12-23T18:57:43.216Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": 510283, | ||
"o": 76, | ||
"u": "http://www.bbc.co.uk/", | ||
"r": 87, | ||
"i": "ydefault", | ||
"lt": 1706 | ||
} | ||
} | ||
} | ||
] | ||
] | ||
} | ||
``` | ||
@@ -83,2 +85,22 @@ | ||
``` | ||
```json | ||
{ | ||
"results": [ | ||
{ | ||
"id": "52b8c2bc1544b91d5a000001", | ||
"timestamp": "2013-12-23T23:09:48.626Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": 510283, | ||
"o": 76, | ||
"u": "http://www.bbc.co.uk/", | ||
"r": 87, | ||
"i": "ydefault", | ||
"lt": 1706 | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
--- | ||
@@ -97,3 +119,3 @@ ### `GET /results` | ||
```bash | ||
curl -i "http://localhost:3000/results?url=http://www.bbc.co.uk?limit=5" | ||
curl -i "http://localhost:3000/results?url=http://www.bbc.co.uk/&limit=5" | ||
``` | ||
@@ -109,17 +131,19 @@ | ||
```json | ||
[ | ||
{ | ||
"id": "52b88b49a3d2f8fd36000001", | ||
"timestamp": "2013-12-23T19:13:13.516Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": 512402, | ||
"o": 76, | ||
"u": "http://www.bbc.co.uk/", | ||
"r": 90, | ||
"i": "ydefault", | ||
"lt": 1825 | ||
{ | ||
"results": [ | ||
{ | ||
"id": "52b8c26e6a9782d25900001a", | ||
"timestamp": "2013-12-23T23:08:30.229Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": "538060", | ||
"o": "76", | ||
"u": "http://www.bbc.co.uk", | ||
"r": "88", | ||
"i": "ydefault", | ||
"lt": "1883" | ||
} | ||
} | ||
} | ||
] | ||
] | ||
} | ||
``` | ||
@@ -155,13 +179,17 @@ --- | ||
{ | ||
"id": "52b88c58a3d2f8fd36000004", | ||
"timestamp": "2013-12-23T19:17:44.822Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": 789301, | ||
"o": 82, | ||
"u": "http://www.bbc.co.uk/weather/", | ||
"r": 48, | ||
"i": "ydefault", | ||
"lt": 2111 | ||
} | ||
"results": [ | ||
{ | ||
"id": "52b8c26e6a9782d25900001a", | ||
"timestamp": "2013-12-23T23:08:30.229Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": "538060", | ||
"o": "76", | ||
"u": "http://www.bbc.co.uk", | ||
"r": "88", | ||
"i": "ydefault", | ||
"lt": "1883" | ||
} | ||
} | ||
] | ||
} | ||
@@ -196,3 +224,3 @@ ``` | ||
```bash | ||
curl -i "http://localhost:3000/results/latest?url=http://www.bbc.co.uk/weather/" | ||
curl -i "http://localhost:3000/results/latest?url=http://www.bbc.co.uk" | ||
``` | ||
@@ -209,13 +237,17 @@ | ||
{ | ||
"id": "52b88c58a3d2f8fd36000004", | ||
"timestamp": "2013-12-23T19:17:44.822Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": 789301, | ||
"o": 82, | ||
"u": "http://www.bbc.co.uk/weather/", | ||
"r": 48, | ||
"i": "ydefault", | ||
"lt": 2111 | ||
} | ||
"results": [ | ||
{ | ||
"id": "52b8c4c2c4dea4fb5c00001b", | ||
"timestamp": "2013-12-23T23:18:26.710Z", | ||
"data": { | ||
"v": "3.1.8", | ||
"w": "538060", | ||
"o": "76", | ||
"u": "http://www.bbc.co.uk", | ||
"r": "88", | ||
"i": "ydefault", | ||
"lt": "1883" | ||
} | ||
} | ||
] | ||
} | ||
@@ -242,6 +274,8 @@ ``` | ||
```json | ||
[ | ||
"http://www.bbc.co.uk/weather/", | ||
"http://www.bbc.co.uk/news/" | ||
] | ||
{ | ||
"urls": [ | ||
"http://www.bbc.co.uk/weather/", | ||
"http://www.bbc.co.uk/news/" | ||
] | ||
} | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
17712
118
273
Updatedyslow-data-service@~0.1.1