Skip to content

Simple self hosted, open source, shorten link service written in Node(Typescript) using DynamoDB

Notifications You must be signed in to change notification settings

jacopobonomi/shorten

Repository files navigation

Tiny self hosted, open source, shorten link service written in Node(Typescript) using DynamoDB.

Features

  • Tiny (build folder 42kb) ✅
  • DynamoDB with AWS SDK as database provider (no configuration) ✅
  • Create (same api for update) short URL ✅
  • Delete short URL ✅
  • Swagger documentation (/links/docs) ✅
  • Clustering mode (for high traffic) ✅
  • Redirects ✅
  • Loggin with morgan ✅
  • Caching for redirects on memory with custom TTL ✅
  • Rate limit on apis ✅
  • Error handling ✅
  • Compression response with gzip ✅
  • nanoID generator ✅

Configuration

cp .env.example .env

Edit .env with yours following variables:

PORT - port to listen on
BASE_URL - base url for shortener service
AWS_REGION - AWS region
LINKS_TABLE_NAME - DynamoDB table name for links
CACHE_TTL - cache TTL for redirects in seconds (default: 60)

To use DynamoDB on you machine you need to install AWS SDK and configure it:

npm install -g aws-sdk
aws configure

and set your region and credentials.

Start

git clone https://github.com/jacopobonomi/shorten
cd shorten
yarn install
yarn start

Development

git clone https://github.com/jacopobonomi/shorten
cd shorten
yarn install
yarn start:dev

Cluster start

git clone https://github.com/jacopobonomi/shorten
cd shorten
yarn install
yarn start:cluster

Server

Use Nginx to manage reverse proxy, certficate and custom domain. And use pm2 to start cluster mode.

pm2 start -1 <NODES_NUMBER> yarn start:

Todo

  • Authentication with API Key for POST/DELETE/PUT
  • Add readble slug for short URL optional parameter
  • Add domain on model, to manage multiple domains
  • Manage wrapper to run on Lambda AWS
  • Add analytics for short URL
  • Add auto exctract short slug from redirect url
  • Add another provider for database (Redis, MongoDB, Firebase(?))>
  • GUI (SolidJS)?

About

Simple self hosted, open source, shorten link service written in Node(Typescript) using DynamoDB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published