Code Monkey home page Code Monkey logo

shorty's Introduction

shorty

Small link shortener

An instance is currently hosted at https://s.flamion.dev if you want to try it out :)

Self-hosting

Currently shorty is intended to be run behind a reverse proxy to take advantage of multiple URLs and https. I personally use nginx, but you can use any reverse proxy you want.

There's multiple ways to run shorty, you can either grab a pre-compiled binary (from a release for example) or you can compile it yourself.

Self compiling

If you have decided to compile it yourself you need to clone this repository. You will also need a functioning rust toolchain.

Once both of these requirements are met, you can compile shorty with cargo build --release. After the compilation is done you can find the resulting binary in the target/release folder which should have appeared.

Configuration

A sample config with the name config.toml.sample is provided in this repository. Alternatively, if it can't find a config file, shorty will create the sample at the config location. The config location by default is next to the binary, but can be customized via the SHORTY_CONFIG environment variable.

Environment Variables

A few things can also be configured via environment variables. Generally most things that can be configured via an environment variable can also be configured via the config file. Shorty will also look for a .env file in the same directory it's executed from and pull environment variables from there.

SHORTY_CONFIG was mentioned before. With it you can set a custom location for the config file. By default shorty will look for the config file in the current folder. This can obviously not be configured via the config file :P

SHORTY_WEBSITE. With this environment variable you can set the location of a custom frontend which should be served instead of the default embedded one.

As time goes on more things might be configurable via environment variable.

Reverse Proxy

If you want HTTPS you currently have to run shorty behind a reverse proxy like nginx. This might change in the future when/if shorty gets the ability to handle HTTPS by itself. If you don't want or need HTTPS then you can also just run shorty on its own. Another reason for a reverse proxy would be hosting shorty alongside other things that require the HTTP(S) port, like a website or another HTTP service.

I personally use nginx but any other reverse proxy should work as well. There is a sample nginx config included in the repository here.

Other things

If there are any questions or other things you would like to talk about, there is a matrix room at #shorty:matrix.netflam.de

shorty's People

Contributors

flamion avatar flareflo avatar zunixorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

zunixorn flareflo

shorty's Issues

Conflict management for non custom links

Currently random IDs are generated if the custom ID is not specified.
If there is a conflict when randomly generating a link, a link can't be created.
Conflicts should be extremely rare with 48 random bits for each link currently, so we should be able to just retry 2-3 times before giving up.

rework build process

currently the frontend needs to be build first with trunk, then the backend can be build. This could be made easier by making one workspace depend on another and also get cargo to build with trunk

affects the Dockerfile, Github Actions and Readme

Update Swagger docs

The endpoint for retrieving the server config is missing from the api docs

null values in json are not handled correctly

when sending a json with either valid_for or max_uses set to null, the return code is 400 Bad Request and a serde error message is returned in the response. The 400 may be wanted although null fields could just be treated as not existing, but the error message should not be a serde parsing error

reproduce with:
http POST https://s.flamion.dev/custom link=do_not_care max_uses=null valid_for=null
or
curl --request POST --header "Content-Type: application/json" --data '{"link":"do_not_care","valid_for":null,"max_uses":null}' https://s.flamion.dev/custom

Rework valid duration selector

Make the valid duration selector switchable between a date selector and a field to enter something like 3 hours or 30 minutes (maybe even just in milliseconds)

Embed assets in binary

The assets (html, js and css) should be embedded in the binary at compile time so shorty works as a standalone binary.

Allow any Cors origin

Allow any CORS origin to make the API callable from other websites too (if there's a custom website on a different origin, or for example things like swagger API).
We could just utilise the actix CORS middleware

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.