@abeai/node-short-url

node.js URL shortener

Usage no npm install needed!

<script type="module">
  import abeaiNodeShortUrl from 'https://cdn.skypack.dev/@abeai/node-short-url';
</script>

README

node-short-url

URL shortener for usage with node.js applications. Supports multiple backends.

Interface

Promise shorten(url[, opts])

Shorten a URL using the requested backend.

opts

  • backendType String

    • Provide a backend type to use or override process.env.NODE_SHORT_URL_BACKEND.
  • backendOptions Object

    • Backend specific options to use for short url generation.

Environment Variables

  • NODE_SHORT_URL_BACKEND
    • Define the short url backend to use. Can override with opts.backendType.

Backends

Firebase

https://firebase.google.com/docs/reference/dynamic-links/link-shortener

Create dynamic links via Firebase's API. Options are provided in the dynamicLinkInfo JSON format.

Default Options

  • suffix.option
    • Defaults to SHORT.

Required Environment Variables

  • NODE_SHORT_URL_FIREBASE_DOMAIN
  • NODE_SHORT_URL_FIREBASE_API_KEY
    • Can pass backendOptions.key to override.