2.0.1 • Published 8 months ago

@quantcdn/quant-client v2.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

QuantCDN client API

Provides a client to common API interfaces on QuantCDN.

Install

The preferred method for installation is via npm.

npm i @quantcdn/quant-client

Usage

  • Import types form '@quantcdn/quant-client' to correctly type parameters
  • All responses are generated using the PaginatedResponse object which provides an async iterator
import { QuantClient, types } from '@quantcdn/quant-client'

const config:types.Config = {
  organization: process.env.QUANT_CUSTOMER,
  project: process.env.QUANT_PROJECT,
  token: process.env.QUANT_TOKEN
}

// If making organization API requests with the client you need to provide bearer
# config.bearer = process.env.QUANT_BEARER_TOKEN

// Create a new client instance.
const client = new QuantClient(config)

// Perform requests to the project API.
const p:types.URLPayload = {"url": "/*"}
client.project.purge(p).then(async res => {
   const r = await res.first()
   console.log(r)
})

// Ping the API to verify details.
client.project.ping().then(async res => {
  const b = await res.first()
  console.log(b)
})

// Access project metadata.
client.project.meta().then(async res => {
  // res.first() will return the first page of the paginated response.
  for await (const i of res) {
    console.log(i)
  }
})

Available methods

The QuantClient class has three properties to access different APIs that are exposed by Quant. These are project, organization, search. Both the project and search clients are project specific.

client.project

MethodDescriptionParameters
pingPing the API to validate credentials
metaAccess the global meta for the project
markupSend a HTML filetypes.MarkupPayload
fileSend a non-HTML filetypes.FilePayload
publishPublish a URLtypes.PublishPayload
unpublishUnpublish a URLtypes.PublishPayload
redirectCreate a redirecttypes.RedirectPayload
proxyCreate an origin proxytypes.ProxyPayload
deleteDelete a resourcetypes.URLPayload
revisionsShow revisions for a URLtypes.URLPayload
purgePurge cache for the given URLtypes.URLPayload

client.organization

MethodDescriptionParameters
wafLogsAccess WAF logs for the organizationtypes.WafLogsPayload

client.search

MethodDescriptionParameters
indexAdd a new item to the indextypes.SearchIndexPayload
removeRemove a URL form the indextypes.URLPayload
clearClear the projects index
statusGet the index status
2.0.1

8 months ago

2.0.0

8 months ago

1.0.0

1 year ago