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

yslow-data-rest-api

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yslow-data-rest-api

REST API for storing YSlow performance data

  • 0.1.2
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

yslow-data-rest-api

A REST API for storing web performance data from YSlow.

It receives test results using YSlow's beacon mechanism and makes them available through a JSON API. Data is persisted to MongoDB with the yslow-data-service package.

Requirements

Installation

npm install yslow-data-rest-api

Usage

Start the server:

yslow-data-rest-api

Configure YSlow to send requests to the beacon end-point. Here's an example with YSlow for PhantomJS:

phantomjs yslow.js -b http://localhost:3000/beacon -i basic http://www.bbc.co.uk/

Head to http://localhost:3000/results to see the test 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
    }
  }
]

Configuration

To start the server on a different port/host then use the -p and -H flags:

yslow-data-rest-api -p 8080 -H localhost

By default the REST API is configured to use a MongoDB database at mongodb://127.0.0.1:27017/yslow. To change this, set the environment variable YSLOW_DATA_DB e.g.

EXPORT YSLOW_DATA_DB="mongodb://127.0.0.1:27017/some_db"

API

POST /beacon

Accepts YSlow beacon requests

Example request
curl -i -X POST -H "Content-Type: application/json" -d '{"v": "3.1.8", "w": 510283, "o": 76, "u": "http://www.bbc.co.uk/", "r": 87, "i": "ydefault", "lt": 1706}' http://localhost:3000/beacon
Example response
HTTP/1.1 201 Created
Location: /results/52b88a9ca7b09dcc36000001

GET /results

Returns stored results

Parameters
  • url - Filters results by URL
  • limit - Limits the number of results returned
Example request
curl -i "http://localhost:3000/results?url=http://www.bbc.co.uk?limit=5"
Example response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
[
  {
    "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
    }
  }
]

DELETE /results

Deletes all results

Example request
curl -i -X DELETE http://localhost:3000/results
Example response
HTTP/1.1 204 No Content

GET /results/:id

Returns a single result by its ID

Example request
curl -i http://localhost:3000/results/52b88c58a3d2f8fd36000004
Example response
{
  "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
  }
}

DELETE /results/:id

Deletes a single result by its ID

Example request
curl -i -X DELETE http://localhost:3000/results/52b88c58a3d2f8fd36000004
Example response
HTTP/1.1 204 No Content

GET /results/latest

Returns the latest result

Parameters
  • url - Returns the latest result for the given URL
Example request
curl -i "http://localhost:3000/results/latest?url=http://www.bbc.co.uk/weather/"
Example response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
  "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
  }
}

GET /urls

Returns the distinct URLs that have been tested

Example request
curl -i "http://localhost:3000/urls"
Example response
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
[
  "http://www.bbc.co.uk/weather/",
  "http://www.bbc.co.uk/news/"
]

Keywords

FAQs

Package last updated on 23 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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