npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pageup

v0.2.0

Published

Do Check If My Page Is UP

Downloads

9

Readme

pageup

Do Check If My Page Is UP

Version Build Status Dependency Status

An easy way to test if your page is available in Node.js, without tying you to any testing framework out there.

toc:

  1. installation
  2. API
  3. CLI
  4. debugging
  5. license

installation:

⇒ npm install pageup

API:

var PageupTest = require("pageup");

new PageupTest(config)

Creates a new test harness.

Example:

var pageupTest = new PageupTest({
  file: "test-description.json"
});

pageupTest.configure(config)

Configures the test harness.

  • config (Object): test configurations. Properties include:
    • files (String[]): array of absolute filepaths
    • file (String): an absolute filepath
    • description (Object): a single test description
    • descriptions (Object[]): array of test descriptions
    • timeout (Integer): number of milliseconds before a request times out. Default is null i.e. a timeout is not applied to the requests.

If both config.files and config.file are provided, config.file will be appended to config.files (if not found in config.files). Similarly for config.description and config.descriptions.

See test description for how the file should be formatted.

You can also use globs. These will be used to find target files. Therefore you don't need to write down all file paths explicitly.

Example:

pageupTest.configure({
    files: ["server.*.js"],
    timeout: 5000,
    descriptions: [
      {
        baseurl: "http://forfuture.co.ke/",
        endpoints: {
          "/": 200
        }
      }
    ]
});

pageupTest.run(tester, done)

Runs your tests.

  • tester (Function): Test the status code
    • signature: tester(err, actual, expected, url)
    • err (Error): truthy, if an error occurring making request such as network failures and request timeouts. Note: 404s and other status codes usually regarded as errors are not passed as err. Status codes do not signify anything specific to pageup.
    • actual (Integer): response status code e.g. 200
    • expected (Integer): expected status code e.g. 404
    • url (String): url the current request was sent to. e.g. "http://localhost:8080/endpoint"
  • done (Function): called when all requests are done
    • signature: done(err)
    • err (Error): truthy, if an error occurs in one of the processing stages prior to testing. An error may occur when reading the target files or converting the file contents to JSON.

Example:

var assert = require("assert");

pageupTest.run(function(err, actual, expected, url) {
    assert.ok(!!err, "error making request to " + url);
    assert.equal(actual, expected, "status code mismatch: " + url);
}, function(err) {
    assert.ok(!!err, "error occurred prior sending requests");
    console.log("we are done");
});

test description:

Tests are described using valid .json files. The following are the required properties:

  • baseurl (String): base url to use to resolve endpoints

These properties are optional:

  • endpoints (Object): mapping of endpoints to expected response status codes
  • ok (Array): an array of endpoints, that we expect status code 200

Sample description file:

{
  "baseurl": "http://localhost:8080",
  "endpoints": {
    "/200": 200,
    "/404": 404,
    "/500": 500
  },
  "ok": [
    "/"
  ]
}

CLI:

The module also provides a command-line interface. Passed arguments are in the format <status-code>=<url>. Ensure url is a valid url.

For example,

⇒ pageup 200=https://duckduckgo.com
✔ (200) https://duckduckgo.com/

You can also ignore the status-code; 200 will be implied.

⇒ pageup https://duckduckgo.com
✔ (200) https://duckduckgo.com/

You can omit the protocol from the url; http will be implied.

⇒ pageup duckduckgo.com
✔ (200) http://duckduckgo.com/

You can specify more than one url.

⇒ pageup duckduckgo.com forfuture.co.ke
✔ (200) http://forfuture.co.ke/
✔ (200) http://duckduckgo.com/

debugging:

To run your tests with debugging output of pageup enabled, set the DEBUG environment variable to pageup.

For example, in *nix:

⇒ DEBUG="pageup"

license:

The MIT License (MIT)

Copyright (c) 2015 GochoMugo [email protected]