uspb = Url Shorter + Paste Bin.
The visitor submits the text. For the text starts with http
, It provider a redirect, otherwise it will display a card with the input text.
It's hosted by Deno, using Deno kv OR Turso database service.
Demo (This is just a demo, no data security guarantees are provided.)
This project supports independent deployment after forking. There are two database options: denokv (recommended) and turso database.
- Fork the repo
- Go to Deno, integrate with your github account.
- Create a project use the repo you just forked.
- Set ENV in your project
SITE_URL='uspb.deno.dev'
PASSWD
is an optional environment variable; if it does not exist, it will not be validated during create short url.
That's all
Turso is a edge database service.
- Fork the repo(use branch turso_as_db as deploy branch)
- Go to Deno, integrate with your github account.
- Create a project use the repo you just forked.
- Go to turso dashborad, create your own database and get the token.
# install the turso CLI
curl -sSfL https://get.tur.so/install.sh | bash
# Create a db
turso auth login
turso db create mydata
# Get the url
turso db list
# Get the token
turso db tokens create mydata
- Create the table with the schema:
# Into SQL CLI;
turso db shell mydata
# in the SQL CLI
create table short_url(
short_code varchar(10) PRIMARY KEY,
url text not null,
access_count integer default 0,
created_at integer default (cast(unixepoch() as int))
);
# Press Ctrl+D for quit
- Set the env in Deno project in
projects -> Setting -> Environment Variables
. Here is example:
SITE_URL='uspb.deno.dev'
TURSO_URL="libsql://xxx.turso.io"
TURSO_TOKEN="..."
PASSWD="Changeme" (Optional)
Run your instance with containers:
docker run -d --name uspb -v ~/vol/uspb:/app/data -p 3000:3000 -e SITE_URL=xxx.com ghcr.io/jneeee/uspb:v0.2
Consider replacing the following options:
Option | Explanation |
---|---|
-v ./xx:/app/data | Persist data in sqlite3 file Outside the container |
-p xx:3000 | the port to expose |
-e SITE_URL= | your site address |