A simple Bun webserver for creating and utilizing url redirects with a PicoCSS driven web front end. Best if used with a short domain name!
|
If you are looking for Shortlinks CLI |
Build the docker image from source locally
docker build -t shortlinks .Start docker container
# Replace /etc/shortlinks with host path to database
# Replace 6134 with desired external port
docker run --name shortlinks -v /etc/shortlinks:/usr/src/app/database -p 6134:80 -d shortlinksor
Step One: Install Bun
# NOTE: Not required for deployment via Docker.
curl -fsSL https://bun.sh/install | bashSHORTLINKS_PORT=7000 # Server will run on this port
bun i # Installs node modules
bun run host # Hosts shortlinks server
# To reset:
bun run clean # Deletes links.db# edit shortlinks.service.template, replacing all <TOKENS> (ctrl-f < works well)
sudo mv shortlinks.service.template /usr/lib/systemd/system/shortlinks.service
sudo systemctl daemon-reload
sudo systemctl enable shortlinks
sudo systemctl start shortlinks❗ To find the absolute path to Bun, run: which bun
Note on that variable. By default, Bun installs to a directory in the user's
home directory, and not on the default $PATH. For this reason we cannot just
run bun through systemd (as it would not be on $PATH and would therefore
not be found). You could alternatively modify this to be bash "bun run host"
which would load in the users .bashrc and add bun to the $PATH.
"method": "POST",
"body": {
"link": "{Link to be directed to}",
"requestedCode": "{OPTIONAL: Path you would like to direct to the link}"
}- 200:
"{Shortlink code (text after '/')}" - 400:
"Missing Destination Link" || "Error Parsing JSON" - 409:
"Request for specific path denied"
Bun is a fast all-in-one JavaScript runtime.
Pico CSS is a Minimal CSS Framework for Semantic HTML.