New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

runscope

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

runscope

Runscope REST API Library

  • 0.0.17
  • latest
  • Source
  • npm
  • Socket score

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

node-runscope

A promise-based library for interacting with the Runscope.

Designed to conform to the structure of the Runscope REST API.

Suggested Usage: https://github.com/louishawkins/node-runscope/blob/master/example.js.

See Runscope API documentation for specific parameters: https://www.runscope.com/docs/api

Get Started

  var runscope = require('runscope')(YOUR_RUNSCOPE_TOKEN);

Methods

List Buckets
  runscope.bucketList();
Create Bucket
  runscope.createBucket(opts);
Account Info
  runscope.account();
Available Service Regions
  runscope.regions();

Bucket Methods

  var myBucket = runscope.bucket(YOUR_BUCKET_KEY);
Bucket Details
  myBucket.detail();
List Tests
  myBucket.listTests();
Find Test By Name
  myBucket.findTestByName('My Test').then(function (myTest) {
      // myTest object has access to all methods
      // outlined under "Test Methods" below.
      myTest.trigger();
  }
Messages API (Traffic Inspector) Methods

A Message for the purposes of this API represents an HTTP request and response pair. Each message can contain a request, a response, or both (most common).

    var opts = {
        count: 50, //int
        since: new Date(), //timestamp
        before: new Date(), //timestamp
    }
    // retrieve all messages
    myBucket.messages(opts);
    // retrieve all errors
    myBucket.errors(opts);
    //retrive shared
    myBucket.shared(opts);
    //retrieve captures
    myBucket.captures(opts);

Test Methods

List Tests
  var myBucketTests = myBucket.tests;
  myBucketTests.list();
Create Test
  var opts = {
      name: 'Test Name',
      description: 'This is a description of the test'
  }

  myBucketTests.create(opts).then(function (newTest) {
      // newTest is a new Test object
      
      var requestOpts = {
          method: 'GET',
          url: 'http://www.google.com'
      }
      newTest
          .addRequest(requestOpts)
          .then(newTest.trigger())
          .then(done);
  }).catch(function (error) {
    //error
  }
Get Test Details
  myTest = myBucket.test(TEST_ID);
  myTest.detail();
Trigger Test
  myTest.trigger();
  
  // results are usually available 
  // after 2 seconds
  myTest
    .trigger()
    .delay(2000)
    .then(function () {
        return myTest.results.latest();
    })
    .then(function (results) {
        console.log(results);
    })
    .catch(function (err) {
      throw new Error(err);
    }
Update Test
  myTest.update(opts);
Delete Test
  myTest.delete();

Test Resources

The Tests object contains four resources:

  Tests.environments
  Tests.results
  Tests.schedules
  Tests.steps

Tests.steps

Add Step
  // step type will default to "request"
  myTest.steps.add(opts);
  
  // more expressively
  myTest.steps.addRequest(opts);
  
  //chain as many as you want
  // Note: currently step order is not guaranteed.
  // See: https://github.com/louishawkins/node-runscope/issues/1
  myTest.steps
    .addRequest(STEP_ONE)
    .addRequest(STEP_TWO)
    .add(STEP_n)
    .then(doStuff)
    .catch();
  
  //other step types
  myTest.addPause({ duration: 2 /* seconds */});
  myTest.addCondition(opts);
  myTest.ghostInspector(opts); //yes even a ghost inspector step
Change Step Order
  myTest.steps.changeOrder(opts);
Step Detail
  myTest.steps.detail(STEP_ID);
Update Step
  myTest.steps.update(STEP_ID, opts);
Delete Step
  myTest.steps.delete(STEP_ID);

Tests.schedules

Create Schedule
  myTest.schedules.create(opts);
Modify Schedule
  myTest.schedules.modify(SCHEDULE_ID, opts);
Show Schedule Details
  myTest.schedules.detils(SCHEDULE_ID);
Delete (stop) a Schedule
  myTest.schedules.delete(SCHEDULE_ID);
  //or
  myTest.schedules.stop(SCHEDULE_ID);

Tests.results

Get Latest Test Result
  myTest.results.latest();
List Test Runs
  myTest.results.list();
Show Details for a Test Run
  myTest.results.detail(TEST_RUN_ID);

Tests.environments

  myTest.environments.list();
  myTest.environments.create(opts);
  myTest.environments.modify(opts);
  myTest.environments.detail(ENV_ID);
  myTest.environments.delete(ENV_ID);

References

Bluebird: http://bluebirdjs.com/docs/api-reference.html

Keywords

FAQs

Package last updated on 24 Jul 2017

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