Socket
Socket
Sign inDemoInstall

superbatu

Package Overview
Dependencies
32
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    superbatu

A Custom URL Shortener


Version published
Maintainers
1
Created

Readme

Source

Superbatu - A Custom URL Shortener

Supebatu helps you build your own URL shortener. The idea is to create your own URL shortening database and host it over expressjs app.

Setup

Install

npm install --save superbatu

Add variables in the ‘.env’ file in the root dir of your service

Superbatu needs a mongo connection, which can be defined with the below configs in .env

SUPERBATU_MONGO_USER="your-mongo-user"
SUPERBATU_MONGO_PASSWORD="your-mongo-pass"
SUPERBATU_MONGO_HOST="your-mongo-host"
SUPERBATU_MONGO_PORT="your-mongo-port"
SUPERBATU_MONGO_DATABASE="your-db-name"
SUPERBATU_MONGO_COLLECTION="your-collection-name"

How to use

create a short url
import { createShortUrl } from 'superbatu';
const { uid, url } = await createShortUrl('https://www.yoursuperlong.url')

uid(a unique identifier for url) and url original URL.

Serve short URL with expressjs
import { shortUrlHandler } from 'superbatu';

const router = express();
router.use('/surl/:uid', shortUrlHandler)

It will redirect to the original long URL.

Keywords

FAQs

Last updated on 22 Jun 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc