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

cloudflare4

v0.2.7

Published

CloudFlare V4 API wrapper

Downloads

2,850

Readme

NPM version Downloads

CloudFlare API v4

The Cloudflare4 module allows you to communicate with the CloudFlare V4 API from node.js in a promise friendly manner.

It also supports automatic request retries.

Installation

This module is published in NPM:

npm install cloudflare4 --save

The --save tells NPM to automatically add it to your package.json file

Usage

// Import a module
var CloudFlareAPI = require('cloudflare4');

// Create an instance with your API V4 credentials
var api = new CloudFlareAPI({email: '[email protected]', key: 'my_key'});

// Get things done
api.userFirewallAccessRuleGetAll().then(function (rules) {
	console.log(rules);
});

Config

new CloudFlareAPI({
	email: '[email protected]',
	key: 'my_key',
	itemsPerPage: 100, // default=100
	maxRetries: 5, // default=5
	raw: false // default=false,
	autoPagination: false, // default=false
	autoPaginationConcurrency: 1 // default=1
});

Pagination

you can pass pagination params into any method that has a body or query argument.

api.userFirewallAccessRuleGetAll({per_page: 1, page: 2}).then(function (rules) {
	console.log(rules);
});

or with auto-pagination

api.userFirewallAccessRuleGetAll({auto_pagination: true, auto_pagination_concurrency: 1}).then(function (rules) {
	console.log(rules);
});

Note: if you use auto_pagination for a GetAll the raw argument is no longer respected

Raw

if you set raw it will return the full response body including pagination details

api.userGet(true)

would return

{
	result: { 
		id: 'dc19c3231tds452eb4ebc123d6eb4c99',
		email: '[email protected]',
		username: 'username',
		first_name: 'Foo',
		last_name: 'Bar',
		telephone: '5555555555',
		country: null,
		zipcode: null,
		two_factor_authentication_enabled: false,
		two_factor_authentication_locked: false,
		created_on: '2014-09-29T13:21:56.807670Z',
		modified_on: '2015-10-04T00:02:50.855108Z',
		organizations: null,
		has_pro_zones: true,
		has_business_zones: false,
		has_enterprise_zones: false
	},
	success: true,
	errors: [],
	messages: []
}

and with raw set to false (the default), it would return

{ 
	id: 'dc19c3231tds452eb4ebc123d6eb4c99',
	email: '[email protected]',
	username: 'username',
	first_name: 'Foo',
	last_name: 'Bar',
	telephone: '5555555555',
	country: null,
	zipcode: null,
	two_factor_authentication_enabled: false,
	two_factor_authentication_locked: false,
	created_on: '2014-09-29T13:21:56.807670Z',
	modified_on: '2015-10-04T00:02:50.855108Z',
	organizations: null,
	has_pro_zones: true,
	has_business_zones: false,
	has_enterprise_zones: false
}

Debugging

we use the debug module so you can debug the http requests by doing the following

DEBUG=http node myfile.js

also all methods enforce type checking so invalid usage would result in errors like this

Debug Example

Methods

All methods follow the official API documentation.

User

User Billing Profile

User Billing History

App Subscription

Zone Subscription

User-level Firewall access rule

User's Organizations

User's Invites

Zone

Zone Plan

Worker Script

Zone Settings

DNS Records for a Zone

Railgun connections for a Zone

Zone Analytics

Railgun

Custom Pages for a Zone

Custom SSL for a Zone

Keyless SSL for a Zone

Firewall access rule for a Zone

WAF Rule Packages

WAF Rule Groups

WAF Rules

Organizations

Organization Members

Organization Invites

Organization Roles

Organization-level Firewall access rule

Page rules for a Zone