An Elixir and CubDB based url shortener.
Devito is designed to be used with the Devito CLI. Although you can also interface it using HTTP.
Authorization is handled via an API token. You must pass auth_token=<VALUE>
with each request, and that token will be matched against the ENV VAR AUTH_TOKEN
. The values cannot be set to nil
.
Configure the application's short_code_chars to a list of values you want the short_code to be generated from.
config :devito, short_code_chars: []
Method | Path | Description | Required Params | Optional Params |
---|---|---|---|---|
GET | /api/ | Index of all links | auth_token=TOKEN | download=true |
POST | /api/link | Create a new link | auth_token=TOKEN; short_code=SHORTCODE; auth_token=TOKEN | |
GET | /api/SHORTCODE | Shows info about a link | - | - |
POST | /api/import | imports JSON links | auth_token=TOKEN; body=JSON | - |
If you are unfamiliar with Gigalixir, they are a hosting service designed for Elixir. This app will work on the free tier and has no need for a postgres database. Watch this tutorial for more information.
- Sign up for an account.
- Follow the steps in the Getting Started Guide. Note: The buildpack config are already included in this repo. Also, there is no need to provision a database.
- Create a new app.
- Set your AUTH_TOKEN from the Gigalixir console > configuration Note: Your auth token will be used to authenticate all API requests
- Deploy the app - It is designed to be deployed using Elixir Releases
- Download the Devito CLI
- Configure the CLI (
./devito config --apiurl <APP URL> --authtoken <TOKEN FROM STEP 4>
) - Test it out.
./devito https://supersimple.org sprsmpl
Gigalixir requires monthly deployments on the free tier. Before deploying, you will need to migrate your existing data.
devito deploy
- export your current data
devito export ~/Desktop
- deploy
git push gigalixir +HEAD:master
- import data
POST api/import
- fish
curl -X POST -H "Content-Type: application/json" -d (cat ~/Desktop/devito_links.json) "<APP URL>/api/import?auth_token=<AUTH TOKEN>"
- bash
curl -X POST -H "Content-Type: application/json" -d "$(cat ~/Desktop/devito_links.json)" "<APP URL>/api/import?auth_token=<AUTH TOKEN>"
An Install walk-through video is available.
Devito Logo by Mark Farris
Before upgrading or redploying, make sure to backup your existing data. You will need to re-import your links after releasing your code.
To start your Phoenix server:
- Setup the project with
mix setup
- Start Phoenix endpoint with
mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix