Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bulk-cuttly-shortener

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bulk-cuttly-shortener

**Note:** This is an unofficial package and is not affiliated with Cuttly Inc.

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
0
Weekly downloads
 
Created
Source

Bulk Cuttly Shortener

Note: This is an unofficial package and is not affiliated with Cuttly Inc.

A Node.js package to shorten multiple links using multiple Cuttly tokens concurrently.

Installation

To install the package, use npm:

npm install bulk-cuttly-shortener

Usage

Importing the Package

First, import the package into your Node.js application:

const { bulkCuttlyShortener } = require('bulk-cuttly-shortener');

Here is a complete example showing how to use the package:

const { bulkCuttlyShortener } = require('bulk-cuttly-shortener');

// Replace with your CUTTLY tokens
const tokens = [
  'YOUR_CUTTLY_TOKEN_1', 
  'YOUR_CUTTLY_TOKEN_2'
];

// Replace with the long URLs you want to shorten
const links = [
  'https://example.com',
  'https://another-example.com'
];

(async () => {
  try {
    const results = await bulkCuttlyShortener(tokens, links);

    // Filter out results with errors
    const successful = results.filter(result => !result.error);
    const failedTokens = results
      .filter(result => result.error)
      .map(result => result.token);

    console.log('Shortened links:', successful);
    console.log('Failed tokens:', [...new Set(failedTokens)]);
  } catch (error) {
    console.error('Error:', error);
  }
})();

Function Details

Parameters:
  • tokens (Array of Strings): An array of CUTTLY API tokens. Ensure tokens are valid and have permissions to shorten URLs.
  • links (Array of Strings): An array of long URLs that you want to shorten.
Returns:

A promise that resolves with an array of results. Each result object includes:

  • token: The CUTTLY token used.
  • link: The original long URL.
  • short_url: The shortened URL if successful.
  • error: An error message if there was a failure.
Error Handling

The package will return results with errors if:

  • A CUTTLY token is invalid or exceeds its rate limit.
  • There are issues with the CUTTLY API request.

The example above demonstrates how to filter results and identify tokens that failed.

Contributing

If you find any issues or have suggestions for improvements, feel free to contribute by creating an issue or submitting a pull request on GitHub.

License

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

Keywords

FAQs

Package last updated on 29 Aug 2024

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