High-performance link shortener

Overview

shorty

High-performance link shortener written in Rust

💾 Hosting

In addition to being easy to build from source, shorty is available as a Docker image on Docker Hub.

🏁 Prerequisites

  • Some sort of Docker or Rust-compatible hosting; clb.li runs on CapRover
  • A persistent Redis database

🌎 Environment variables

  • DB_URL - a valid Redis URL, e.g. redis://localhost:1234
  • TOKEN - your desired API token; only required if you're using the API (described below).

⚙️ Server configuration

Configure the server through environment variables or Rocket.toml; check this guide for more information. shorty runs on port 8000 by default.

📡 API

Use shorty's API to add/remove links.

Authentication

Provide your TOKEN (described above) as a bearer token, so set the Authorization header to Bearer <token>. Example: curl -H "Authorization: Bearer token1234" http://localhost:8000/api/example/route

Requests

POST requests must all contain JSON payloads. x-www-form-urlencoded is not supported.

Responses

All responses are JSON, and follow this rough schema:

{
  // False if something went wrong
  "ok": true,

  // Will be a string if something went wrong
  "err": null,

  "data": {
    // Response data here...
  }
}

POST /api/link - create or update a named link

Options:

  • url (string, required) - The URL the redirect to.
  • name (string, optional) - The link's name. Leave blank to randomly generate a 10-character ID.
  • public (bool, optional) - Whether or not to display this link on the public links page; coming soon

ℹ️ Note: / is a special value for <name> that creates a redirect for the root URL.


DELETE /api/link/<name> - delete a named link

example: curl -X DELETE http://localhost:8000/api/link/gh

ℹ️ Note: Please URL encode the <name> parameter if necessary; / will become %2F


🚗 Roadmap

  • UI
  • Redirect code configuration
Comments
  • Empty link can be created but not destroyed

    Empty link can be created but not destroyed

    I can create a link with an empty name by specifying { "name": "" } as my input. this link doesn't appear to do anything (it doesn't affect the root redirection). But unfortunately I can't delete it, because I can't name it.

    Expected behavior:

    I expected the POST with { "name": "" } to either fail, or to behave as though "name" were not specified (i.e. generate a random name). I should not be able to create a link with no name.

    My preferred behavior is "behave as though 'name' wasn't specified". That makes it a bit easier to script the API since I don't need to conditionally include the name field.

    opened by lilyball 1
  • `PATCH` can still create links with empty name

    `PATCH` can still create links with empty name

    If I create a link, and then send a PATCH with { "name": "" }, shorty will happily change the name to be empty, thus preventing it from ever being referenced again (including being destroyed). See https://github.com/cjdenio/shorty/issues/11.

    For comparison, PATCH with { "name": null } behaves as though the "name" key weren't present. Though treating "name": "" as though it weren't present at all may be a bit surprising.

    I think the right behavior here is to treat PATCH with { "name": "" } as an error. Having that (or "name": null) randomize the name might be surprising.

    opened by lilyball 0
  • `POST` to `api/link` with `

    `POST` to `api/link` with `"name" = null` causes 422 response

    If I issue a POST to api/link with "name": null I get a 422 Unprocessable Entity response. It would be more convenient if passing null behaved the same as omitting the key entirely. This would make it easier for me to script the API.

    opened by lilyball 0
  • Allow TOKEN_FILE to specifiy a token instead of using TOKEN

    Allow TOKEN_FILE to specifiy a token instead of using TOKEN

    This lets you specify a file TOKEN_FILE, from which the contents are read. TOKEN takes precedence over this. The main use case for this, right now, is a NixOS module I'm writing (it'd be bad to leave the token in a flake).

    opened by CodeLongAndProsper90 0
  • I can mix `

    I can mix `"description": ""` and `"description": null` in my links

    When creating links with the API, omitting the description key entirely or passing { "description": null } produces a link with "description": null. However if I pass an empty string ({ "description": "" }) I get back a link with "description": "". AFAIK this doesn't affect the behavior of the link redirector, but it is annoying from an API perspective as it means I have to check if the description is empty instead of just checking if it's non-null.

    Expected behavior:

    Passing { "description": "" } should produce a link with { "description": null }. Any links I retrieve with GET api/links should ensure the description is either null or non-empty.

    opened by lilyball 0
Owner
Caleb Denio
Full-time Go enthusiast, part-time turtle, and all-the-time @hackclub member! None of my work is in private repos 🙈
Caleb Denio
A modest URL shortener for personal usage.

bref A modest URL shortener for personal usage. Shortens URLs to a 6 characters-length key that is generated based on current time. Why? Why not? Usag

Nicolas Gryman 3 Oct 8, 2023
Rust library that helps you change the domain of the link to another domain 🦀🔐

Rust library that helps you to change the domain of the link to another domain, the library helps with privacy. It can be used to change the domain of sites that do not care about privacy to another that does.

TheAwiteb 2 Mar 28, 2022
📡Proxy HTTP/1.1 requests over a sensitive point-to-point link

ptproxy Motivation What's this? Why do I need this? What's a sensitive network link? What's wrong with a VPN? What's wrong with HTTP[S]? What's wrong

Alba Mendez 5 Jul 26, 2023
A high performance TCP SYN port scanner.

Armada A High-Performance TCP SYN scanner What is Armada? Armada is a high performance TCP SYN scanner. This is equivalent to the type of scanning tha

resync 259 Dec 19, 2022
Drpc-Correct, high performance, robust, easy use Remote invocation framework

Drpc - Correct, high performance, robust, easy use Remote invocation framework

darkrpc 30 Dec 17, 2022
High performance I/O framework written by Rust inspired by Netty

Introduction Retty is a High performance I/O framework written by Rust inspired by Netty 基于mio的IO多路复用高并发、高性能网络通信开发框架 Feature Rayon 线程池包装 EventLoop / E

lgphp 9 Dec 25, 2022
Volo is a high-performance and strong-extensibility Rust RPC framework that helps developers build microservices.

Volo is a high-performance and strong-extensibility Rust RPC framework that helps developers build microservices.

CloudWeGo 1.3k Jan 2, 2023
A high performance/low-overhead OpenMetrics library for Rust

* * * EXPERIMENTAL * * * discreet-metrics A high-performance/low-overhead metrics library aiming to conform with OpenMetrics and to satisfy the follow

null 2 Sep 14, 2022
Cloud Native high performance security and privacy SQL proxy.

Fern proxy With the advent of Cloud Native applications, architecture patterns evolved and emerged to take advantage of cloud computing, and build mor

Fern 12 Nov 7, 2022
🚀 10x easier, 🚀 10x cheaper, 🚀 high performance, 🚀 petabyte scale - Elasticsearch/Splunk/Datadog alternative for 🚀 (logs, metrics, traces).

?? 10x easier, ?? 10x cheaper, ?? petabyte scale - Elasticsearch/Splunk/Datadog alternative for ?? (logs, metrics, traces). ZincObserve ZincObserve is

Zinc Labs Inc. 80 Feb 22, 2023
The High Performance Proxy/Load Balancer

Silverwind-The Next Generation High-Performance Proxy English 简体中文 The Silverwind is a high-performance reverse proxy/load balancer. And it could be a

null 112 Apr 7, 2023
A library-first, lightweight, high-performance, cloud-native supported API gateway🪐 by RUST

Preview version, will not guarantee the stability of the API! Do NOT use in production environment! A library-first, lightweight, high-performance, cl

Ideal World 4 May 7, 2023
A high-performance, lightweight, and cross-platform QUIC library

TQUIC English | 中文 TQUIC is a high-performance, lightweight, and cross-platform library for the IETF QUIC protocol. Advantages High performance: TQUIC

Tencent 11 Oct 27, 2023
TCP is so widely used, however QUIC may have a better performance.

TCP is so widely used, however QUIC may have a better performance. For softwares which use protocols built on TCP, this program helps them take FULL advantage of QUIC.

zephyr 15 Jun 10, 2022
An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

null 2 Apr 27, 2022
A high performence Socks5 proxy server with bind/reverse support implementation by Rust.

rsocx A high performence Socks5 proxy server with bind/reverse support implementation by Rust Features Async-std No unsafe code Single executable Linu

b23r0 259 Jan 6, 2023
A link shortener

Goxidize A link shortener. Perquisites Rust 1.56+ npm CLI and Node.js Any officially supported PostgreSQL Build Before building the project, please cr

Zixian Cai 4 Nov 16, 2022
A very-very simple url shortener for Rust

urlshortener-rs A very simple urlshortener for Rust. This library aims to implement as much URL shortener services as possible and to provide an inter

Victor Polevoy 39 Nov 20, 2022
A mini paste bin and url shortener written in rust without databases.

pb Build $ cargo build --release Environment Variables PB_DATA: /some/path (Default: ./pb_data) PB_SITE: Url of your site. (Default: http://localhost:

Edward P 5 Jul 26, 2022
A URL shortener that uses emojis, only emojis.

emojied Shorten your URLs with emojis! Features Well, shorten your URLs! Customize what emoji to use. e.g Want to use an eggplant emoji? Sure, as long

SEKUN 99 Dec 31, 2022