Nostalgic Pizza Manager

    shortener-url-with-domain

    1.0.7 • Public • Published

    Link shortener with custom redirect

    How to use

    Use the command npm or yarn for the button installation

    ![NPM version]

    npm install --save shortener-url-with-domain
    

    Or

    yarn add shortener-url-with-domain
    

    Example

    note: CommonJsUsage

    In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require() use the following approach:

    const { shortener } = require("shortener-url-with-domain");

    Usage

    the function shortener expects two parameters of which only the url is mandatory, by default it returns the shortened url with our domain name.

    const { shortener } = require("shortener-url-with-domain");
    
    /*
     * @params url = https://www.google.com
     * @return shortUrl = 01mz
     */
    export const createUrl = async (url: string) => {
      let shortUrl = await shortener(url);
      return shortUrl;
    };

    or

    If you want the clipped url to have your domain it would be:

    const { shortener } = require("shortener-url-with-domain");
    
    /*
     * @params url = https://www.google.com
     * @params domain = 'YOUR REDIRECT URI' -> Format : https://example.com/
     * @return shortUrl = https://example.com/01mz
     */
    const createUrl = async (url: string) => {
      let shortUrl = await shortener(url);
      return shortUrl;
    };

    Mandatory Parameters

        url: string -> (required)
        domain: string -> (optional)

    Usage Custom Redirect

    In the path you indicated to the previous method you must send to the getUrl function only the shortUrl example:

    const { getUrl } = require("shortener-url-with-domain");

    Usage

    const { getUrl } = require("shortener-url-with-domain");
    
    /*
     * @params shortUrl = 01mz
     * @return url = https://google.com
     */
    const returnUrl = async (shortUrl: string) => {
      let completeUrl = await getUrl(shortUrl);
      return completeUrl;
    };

    Install

    npm i shortener-url-with-domain

    DownloadsWeekly Downloads

    304

    Version

    1.0.7

    License

    ISC

    Unpacked Size

    13 kB

    Total Files

    15

    Last publish

    Collaborators

    • rickmy