Giter VIP home page Giter VIP logo

node-kutt's Introduction

Kutt

Node.js & browser (TypeScript) client for Kutt url shortener.

NPM Version Test NPM Monthly Downloads NPM Total Downloads NPM Bundle Size (minified) NPM Bundle Size (minified + gzip) Known Vulnerabilities Pull Requests License Github Stars Github Forks

Table of Contents

Installation

npm i kutt

Usage

CommonJS

const Kutt = require("kutt").default;

or

const { Kutt } = require("kutt");

ECMAScript

import Kutt from "kutt";

or

import { Kutt } from "kutt";

Default Config

Get

const api: string = Kutt.get("api");

const key: string = Kutt.get("key");

const timeout: number = Kutt.get("timeout");

Set

Kutt
  .set("api", "https://kutt.it/api/v2") // API base url (Default value)
  .set("key", "") // API key (Default value)
  .set("timeout", 1e4); // Request timeout (Default value)

Instance

const kutt = new Kutt();

Instance Config

Override the default config only for the instance.

Get

const api: string = kutt.get("api");

const key: string = kutt.get("key");

const timeout: number = kutt.get("timeout");

Set

kutt
  .set("api", "https://kutt.it/api/v2") // API base url
  .set("key", "") // API key
  .set("timeout", 1e4); // Request timeout

Domains

const domains = kutt.domains();

Create

Create a domain.

const domain = await domains.create({
  address: "string",
  homepage: "string",
});

Delete

Delete a domain.

const message = await domains.remove(domain.id);

Health

const health = kutt.health();

Check

Check API health.

const isHealthy = await health.check();

Links

const links = kutt.links();

List

Get list of links.

const result = await links.list();

You can also pass in pagination params.

const result = await links.list({
  skip: 0, // Default value
  limit: 10, // Default value
  all: 10, // Default value
});

Create

Create a short link.

const link = await links.create({
  target: "string",
  description: "string",
  expire_in: "2 minutes/hours/days",
  password: "string",
  customurl: "string",
  reuse: false,
  domain: "string",
});

Stats

Get link stats.

const stats = await links.stats(link.id);

Update

Update a link.

const updatedLink = await links.update(link.id, {
  target: "string",
  address: "string",
  description: "string",
  expire_in: "2 minutes/hours/days",
});

Delete

Delete a link.

const message = await links.remove(link.id);

Users

const users = kutt.users();

Info

Get user info.

const info = await users.info();

Versioning

We use SemVer for versioning. For the versions available, see the releases on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

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.