Skip to content

URL shortener written in Node.js. App is generating routes by variables in .ENV. Simple and powerful.

License

Notifications You must be signed in to change notification settings

mativizo/env-url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

env-url-shortener

URL shortener written in Node.js. App is generating routes by variables in .ENV. Simple and powerful. No databse, no json files, just env.

How to use

  1. Clone repository: git clone https://github.com/mativizo/env-url-shortener.
  2. Install dependencies: npm i.
  3. Set your urls in env.
  4. Run npm start.

How to add urls to .env?

Simply, use:

URL_<unique_name>_ID=slug_here
URL_<unique_name>_GO=url_here.com

For example:

URL_1_ID=yt
URL_1_GO=youtube.com
URL_2_ID=google
URL_2_GO=google.com
URL_3_ID=gh
URL_3_GO=https://github.com

127.0.0.1:3000/yt -> https://youtube.com 127.0.0.1:3000/google -> https://google.com 127.0.0.1:3000/gh -> https://github.com

How to change prefix?

To change variables prefix (URL_ by default), set VAR_PREFIX variable in env:

VAR_PREFIX=X_
X_1_ID=yt
X_1_GO=youtube.com
X_2_ID=google
X_2_GO=google.com
X_3_ID=gh
X_3_GO=https://github.com

How to set redirect for main domain?

If you want to redirect main domain, you can set link like this:

VAR_PREFIX=URL_
URL_MAIN_ID=*
URL_MAIN_GO=google.com

by using * in ID (slug) the main domain or / route will redirect to selected url.

About

URL shortener written in Node.js. App is generating routes by variables in .ENV. Simple and powerful.

Topics

Resources

License

Stars

Watchers

Forks