A URL shortener that uses emojis, only emojis.

Overview

emojied

Docker Image Size (latest by date)

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 as it's not taken!
  • Not sure what emoji to use? emojied autogenerates one for you.
  • View URL clicks (simple stats for now)
  • Leaderboard - See the top 20 most clicked links!
  • Do you hate enabling JS? Well, this works completely fine with JS disabled!*

* If you're using an extension to disable JS, then this will depend on if they copied the noscript tag attributes cause the ones I've used don't. It's a bug.

Getting Started

For the dev environment, it's fairly simple to set up the project if you're already using Nix (with Flakes). If not, then you'll need to get the dependencies yourself; sorry!

Here are the versions of the important ones:

  • rustc: 1.58.1
  • cargo: 1.58.0
  • postgresql: 14.1
  • sqitch: 1.1.0
  • tailwindcss: 3.0.23
  • esbuild: 0.14.27
  • typescript: 4.6.2
  • openssl: 1.1.1n 15 Mar 2022

Everything else doesn't matter too much I think. You could probably just use whatever version of rust-analyzer you have, for example.

However, if you do have Nix 2.7.0 (with Flakes), you probably know how to use it anyway. nix develop (or don't if you have nix-direnv already), and dev away.

Oh, you also have to set up the database called emojied_db (locally).

Once you've done whatever to get all the dependencies, you can do the ff:

sqitch deploy

# You can also do `cargo run` if you don't want to use `cargo-watch`.
PG__DBNAME="YOUR_DB_NAME_HERE" PG__HOST="localhost" PG__USER="YOUR_USER_HERE" PG__PORT="5432" A
PP__STATIC_ASSETS="./public" cargo watch -x run

This should run a server in port 3000, which you can access in http://localhost:3000.

Oh, you want to set it up for a prod server? But why? (continue reading)

Prepping the binary for prod

You'll need the binary to run the server. You can prep it in a few ways:

Docker image

A docker image is available here: https://hub.docker.com/r/hsekun/emojied

Pre-built binary

NOTE: The binary requires some dynamic libs. Haven't figured out a way to get a static binary working. I wasn't able to double check properly.

Build from source

You can build the binary, and static assets with nix. You can also build it some other way if you prefer, but I'm not gonna bother with that.

Options:

  1. nix build: Builds emojied's + static assets, and provides an APP__STATIC_ASSETS environment variable. This is the "wrapped" version.
  2. nix build .#emojied-unwrapped: Like above, but doesn't provide the env variable.

In both, everything is already taken care of. #1 is more suitable for distributing it as an application.

Build a Docker image

If ever you need a Docker image with emojied, then you'll need nix (flakes) to build it.

# Build the Docker image tar
nix build .#emojied-docker

# Load result to Docker
docker load < result

From this, you get a Docker image emojied-docker:latest! If you want an example, you can check out the .github/workflows/main.yml.

Environment variables

emojied requires you to provide some environment variables, namely the ff:

  • APP__STATIC_ASSETS (required, path that directly contains app.css, etc.): Path of public/
  • APP__PORT (optional, defaults to 3000)
  • PG__HOST (required)
  • PG__DBNAME (required)
  • PG__USER (required)
  • PG__PASSWORD (optional, defaults to nothing)
  • PG__PORT (required)
  • PG__POOL_SIZE (optional, defaults to 22)
  • PG__CA_CERT (optional, defaults to No TLS): CA certificate's file path
  • CA_CERT (optional): CA certificate's contents. This shouldn't contain the BEGIN and END certificate headers. See bin/run.

Schema migrations

Finally, you'll need to migrate the database emojied will use. I'm using sqitch cause I'm poor, and need a schema migration tool that doesn't come with broken kneecaps in the free tier. sqitch gets the job done here, and it's OSS.

SQITCH_PASSWORD="YOUR_DB_PASSWORD_HERE" sqitch deploy \
  --db-host YOUR_DB_HOST_HERE \
  --db-port YOUR_DB_PORT_HERE \
  --db-user YOUR_DB_ADMIN_USERNAME_HERE \
  --db-name YOUR_DB_NAME_HERE

Of course, replace the YOUR_*_HERE with your actual database credentials. It should say ok for everything. If it doesn't then you probably set something up in the DB incorrectly. Oh, the device you're running this command on, whether it be local or in some CI, it needs to be added to the trusted sources so that you can actually communicate with the DB. I just temporarily add my PC as one of the trusted sources, then remove it after I've performed the migrations.

Comments
  • Chore/refactor flake

    Chore/refactor flake

    • [x] Retire flake-utils since I'm not going to target other platforms
    • [ ] Appease nix flake check deprecation notices cause I recently upgraded to nix 2.7 (devShells.<system>.default) breaks nix-direnv so maybe later.
    opened by sekunho 0
  • chore: Deploy

    chore: Deploy

    sqlx's compile time verification is inconvenient when it comes to building a binary without any connection to the DB. So if I were to build in a Docker container, I'd have to go through more hoops just to get it to work, which is not very convenient. query() is also not as "good" as its macro counterparts because I get weird compiler panics for almost everything, and I can't be arsed to debug that. e.g (https://pastebin.com/raw/vPrFZcyD). Not knowing makes me less confident if I should open an internal compiler bug report.

    For some reason, the type inference is not very good when it comes to SQLx. I get unknowns almost all the time.

    So I could just use a combination of tokio-postgres + deadpool-postgres + tokio-pg-mapper to get the stuff I want.

    opened by sekunho 0
  • refactor: Migrate to `sqlx`

    refactor: Migrate to `sqlx`

    SQLx has some conveniences that is absent from tokio-postgres like out-of-the-box pooling, and compile-time verification. It has a somewhat better API but I'm still annoyed by the fact that columns that are guaranteed not to be null due to the NOT NULL constraint are still wrapped in Option.

    opened by sekunho 0
  • feat: Generate a random emoji string

    feat: Generate a random emoji string

    tiny_id mentioned that when it runs into a collision, it increases the length. I haven't really read to much into this though so it may be a problem if ever I didn't read it properly, which I probably did not.

    opened by sekunho 0
  • feat: Add 404 page

    feat: Add 404 page

    emojied will render the 404 page when:

    • The route doesn't exist
    • The identifier doesn't match anything in the db
    • If it's not an emoji when you're looking something up
    opened by sekunho 0
Releases(v0.1.4)
Owner
SEKUN
λ PL is fun.
SEKUN
Enum path && dir on target URL. Powered by Rust ! 🦀

enum-dir 一款快速枚举目录的小工具,使用 Rust 编写,扫起来真的很快。 用于发现目标站点中可能存在的路径信息,同时支持字典模式和暴力枚举模式。 本工具仅用于学习 Rust 以及 Rust 协程 Tokio 使用,严禁用于非法用途。 如果使用本工具从事违法犯罪活动,造成的任何后果,本人不承

lightless 9 Nov 20, 2022
Rust GraphQL server using simple type-only schema

SimpleGQL This library allows a simplified GraphQL schema to be given and will run a server with a backend store (currently only SQLite) and a set of

Daniel Cocks 5 May 10, 2023
A simple url checker for finding fraud url(s) or nearest url

urlchecker A simple url checker for finding fraud url(s) or nearest url while being fast (threading) Eg:- use std::collections::HashMap; use urlchecke

Subconscious Compute 2 Aug 7, 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
Shurly, this is a URL shortener with API management

Shurly Shurly, this is a URL shortener with API management Features Management of destinations through a REST'ish API Permanent/temporary redirects; p

WorkplaceBuddy 3 Nov 30, 2022
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
High-performance link shortener

shorty High-performance link shortener written in Rust ?? Hosting In addition to being easy to build from source, shorty is available as a Docker imag

Caleb Denio 49 Jan 3, 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 lightweight and snappy crate to remove emojis from a string.

A lightweight and snappy crate to remove emojis from a string.

Tejas Ravishankar 8 Jul 19, 2022
Converts between country names, ISO 3166-1 codes and flag emojis.

country-emoji Converts between country names, ISO 3166-1 codes and flag emojis. Usage use country_emoji::{flag, code, name, countries}; flag("CL") /

Leo Dutra 4 Oct 25, 2022
A transpiler/compiler for CrabRave, a version of BrainFuck with sea-life emojis.

CrabRave Programming Language CrabRave is a fun and unique programming language based on Brainfuck, which utilizes crab and sea-life emojis as its syn

null 23 May 3, 2023
Easily add emojis to your git commit messages 😎

gimoji A CLI tool that makes it easy to add emojis to your git commit messages. It's very similar to (and is based on) gitmoji-cli but written in Rust

Zeeshan Ali Khan 12 May 29, 2023
url parameter parser for rest filter inquiry

inquerest Inquerest can parse complex url query into a SQL abstract syntax tree. Example this url: /person?age=lt.42&(student=eq.true|gender=eq.'M')&

Jovansonlee Cesar 25 Nov 2, 2020
url cleaner

Clink Have you ever pasted a link in messenger and deleted all those fbclid, utm_source, and so on, GET params by hands? Clink does that for you. It s

Serhiy Barhamon 19 Dec 14, 2022
Obsidian Plugin: Convert a URL into markdown

Obsidian Plugin: Convert a URL into markdown Transforms a URL to markdown view if the website allows it. Installation Available in the community plugi

Stephen Solka 142 Jan 3, 2023
image url web-scrapper written in rust

imgs - CLI Webscrapper image url web-scrapper written in rust This is a cli application completely written in rust, it aim is to scrap image-url from

Michael Olayemi 1 Apr 2, 2022
A command-line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the returned URL.

Pup A command line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the return

SteveLau 11 Aug 17, 2022
Small crate to work with URL in miniquad/macroquad.

quad-url This is the crate to work with URL and open links in miniquad/macroquad environment. Web demo. Usage Add this to your Cargo.toml dependencies

ilya sheprut 3 Jun 11, 2022
A dead simple human-writable URL redirector based loosely on google's `go/` system.

Redirector a redirector written in rust intended for permanent human-readable redirects. The idea was semi-inspired by the book Software Engineering a

Jan Harasym 4 Dec 14, 2022