A short url service.
$ git clone https://github.com/zce/short.git
$ cd short
$ cp .env.example .env
$ vi .env # add your upstash redis url & token
$ npm install
$ npm run develop
UPSTASH_REDIS_REST_URL
: Upstash redis rest url.UPSTASH_REDIS_REST_TOKEN
: Upstash redis rest token.
Create a new short url.
$ curl https://t.zce.me/create -d "url=https://zce.me" -d "slug=zce"
url
: target urlslug
: short slug, optional, default:auto nanoid
{
"slug": "<slug>",
"link": "http://t.zce.me/<slug>"
}
POST http://localhost:3000/create HTTP/1.1
# {
# "error": "Bad Request",
# "message": "Illegal body: unexpected end of JSON input."
# }
POST http://localhost:3000/create HTTP/1.1
content-type: application/json
{}
# {
# "error": "Bad Request",
# "message": "Missing required parameter: url."
# }
POST http://localhost:3000/create HTTP/1.1
content-type: application/json
{
"url": "https://www.google.com"
}
# {
# "slug": "bPVp",
# "link": "http://localhost:3000/bPVp"
# }
POST http://localhost:3000/create HTTP/1.1
content-type: application/json
{
"url": "https://www.google.com",
"slug": "google"
}
# {
# "slug": "google",
# "link": "http://localhost:3000/google"
# }
POST http://localhost:3000/create HTTP/1.1
content-type: application/json
{
"url": "https://www.google1.com",
"slug": "google"
}
### Redirect to url
```http
GET http://localhost:3000/google HTTP/1.1