GithubHelp home page GithubHelp logo

ifvictr / rebrandly.js Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 57 KB

⚡ A promise-based client for the Rebrandly API in Node.js

Home Page: https://npm.im/rebrandly

License: MIT License

JavaScript 100.00%
api branding link rebrandly rebrandly-com

rebrandly.js's Introduction

rebrandly.js

A promise-based client for the Rebrandly API in Node.js.

Installation

npm install rebrandly --save

Usage

const Rebrandly = require("rebrandly");
const client = new Rebrandly({
    apikey: "API_KEY_HERE",
    // `workspace` is optional
    workspace: "WORKSPACE_HERE"
});

// Output all shortlinks and the destinations they point to
client.links.list().then(res => {
    for(const link of res) {
        console.log(`${link.domainName}/${link.slashtag} -> ${link.destination}`);
    }
});

Methods

Methods in this module wrap around the REST API specified here: https://developers.rebrandly.com

  • rebrandly.account.get()
  • rebrandly.account.getTeams(params)
  • rebrandly.account.getWorkspaces(params)
  • rebrandly.domains.count(params)
  • rebrandly.domains.get(id)
  • rebrandly.domains.list(params)
  • rebrandly.links.count(params)
  • rebrandly.links.create(params)
  • rebrandly.links.delete(id, params)
  • rebrandly.links.get(id)
  • rebrandly.links.getScripts(id, params)
  • rebrandly.links.getTags(id, params)
  • rebrandly.links.list(params)
  • rebrandly.links.update(id, params)
  • rebrandly.scripts.count()
  • rebrandly.scripts.create(params)
  • rebrandly.scripts.delete(id)
  • rebrandly.scripts.get(id)
  • rebrandly.scripts.list(params)
  • rebrandly.scripts.update(id, params)
  • rebrandly.tags.count()
  • rebrandly.tags.create(params)
  • rebrandly.tags.delete(id)
  • rebrandly.tags.get(id)
  • rebrandly.tags.list(params)
  • rebrandly.tags.update(id, params)

License

MIT

rebrandly.js's People

Contributors

dependabot[bot] avatar ifvictr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cre8rdao

rebrandly.js's Issues

Add unit tests

Each test will test one functionality. Tests will be located under test/ and use the AVA testing framework.

Add usage examples

Each script will demonstrate one functionality of the package. All examples will be located under examples/.

Don't unnecessary expose data in requests

Client._request's takes an object of key/value pairs for the data parameter and passes it as the value for qs and body. Potentially sensitive information is being exposed in qs, because it will be in request logs. The solution is to look for values with a valid key and delete them when they're no longer necessary.

Changes to make:

Client.js:

_request(method, uri, data, keys) {
    return axios({
        method: method,
        baseURL: "https://api.rebrandly.com/v1/",
        url: uri,
        params: data.get(keys.query),
        headers: {
            apikey: this.apiKey,
            ...data.get(keys.header)
        },
        data: data.get(keys.body),
        responseType: "json"
    }).then(({data}) => data);
}

Link.js:

list(params) {
    return this.client.get("/links", params, {
        query: [
            "domain.id",
            "status",
            "favourite",
            "orderBy",
            "orderDir",
            "offset",
            "limit"
        ],
        header: [
            "workspace"
        ]
    });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.