Pageload-Timer

A web service template written in NodeJS with the Express.js web framework. Downloads a given list of web pages, and returns an array of their pageload latencies in milliseconds. Demonstrates various development best practices, including self-documenting BDD unit tests in Mocha Chai & Expect.js. Continuously Deployed on Heroku ExpressJS with Grunt & Travis CI.

Build Status Coverage Status

Sample Request

{
    "payload": [
            "http://www.google.com",
            "https://www.facebook.com:443",
            "https://twitter.com",
            "http://www.xkcd.com/443?foo=bar"
    ]
}

Sample Response

{
    "response": [
        {
            "url": "http://www.google.com",
            "latency_ms": 3210
        },
        {
            "url": "https://www.facebook.com:443",
            "latency_ms": 1232
        },
        {
            "url": "https://twitter.com",
            "latency_ms": 315
        },
        {
            "url": "http://www.xkcd.com/443?foo=bar",
            "latency_ms": 132
        }
    ]
}

Object Diagram

alt tag

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install pageload-timer --save

Tests

  The Pageload Timer Web Service: 
    √ Should Return 4 Valid Timing Records Given Sample Request (2802ms)
    √ Should Return Single Response Given Single Existing URL (1788ms)
    √ Should Return 404 Not Found Given Well-Formed Non-Existing URL (387ms)
    √ Should Return 404 Not Found Given Invalid TLD (383ms)
    √ Should Return 400 Parse Error Given Invalid Schema
    √ Should Return 400 Parse Error Given Invalid MIME Type
    √ Should Return 400 Parse Error Given Non-JSON Request
    √ Should Return 404 Not Found Given Invalid POST Path
    √ Should Return 400 Parse Error Given Missing Request
    √ Should Return 400 Parse Error Given Null Request
    √ Should Return 400 Parse Error Given Empty JSON Request
    √ Should Return 400 Parse Error Given Empty String Request
    √ Should Return 400 Parse Error Given Empty Payload
  The Test Data: 
    √ sampleRequest Should Return 4 String Elements
    √ Request.isValid Should Return True Given sampleRequest
    √ Request.isValid Should Return False Given emptyRequest
    √ Response.isValid Should Return True Given sampleResponse
    √ Response.isValid Should Return False Given emptyResponse
    √ sampleResponse Should Contain Same URLs As sampleRequest
  19 passing (5s)

Documentation

System Internals are documented using JSDoc here.

Dependencies

Dev Dependencies

License

MIT

Generated by package-json-to-readme