URL shortener written in Node.js. App is generating routes by variables in .ENV. Simple and powerful. No databse, no json files, just env.
- Clone repository:
git clone https://github.com/mativizo/env-url-shortener
. - Install dependencies:
npm i
. - Set your urls in env.
- Run
npm start
.
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
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
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.