node-url-shorten

1.0.1 • Public • Published

URL Shortener

NodeJS module to create aliases (using Base62 conversion) for long url mapped to a unique counter. Users are redirected to the original URL when they hit these short links.

Want to contribute to url-shortner? Please read CONTRIBUTING.md.

Technologies used

- NodeJS
- MongoDB

Installation

URL-Shortener supports stable versions of Node.js 8.11.0 and later. You can install URL-Shortener in your project's node_modules folder.

To install the latest version on npm locally and save it in your package's package.json file:

npm install --save node-url-shorten

Usage

  • Initialize URL Shortener Object
  const URLShortener = require('node-url-shorten');
 
  const options = {
      characters: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
      minHashCount: 4,
      domain: "https://click.com"
  }
 
  const shortUrl = new URLShortener(mongodb, errorCallback, options);
  • Shorten URL
  shortUrl.shortenUrl('https://client.example.com/user/1', new Date("2025-02-01"))
      .then(res => console.log('res' , res))
      .catch(err => console.log(err));
  • Retrieve Long URL from hash
  shortUrl.retrieve('0004')
   .then(orgUrl => redirect(orgUrl.URL))
   .catch(err => console.log(err));

Documentation

License

URL Shortener is copyright (c) 2019-present Anish Lushte and the contributors to URL Shortener.

URL Shortener is free software, licensed under the MIT License. See the LICENSE file for more details.

Package Sidebar

Install

npm i node-url-shorten

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

1.06 MB

Total Files

42

Last publish

Collaborators

  • anishlushte