Caution
Deta Space has shut down. This project is no longer maintained.
An API to setup custom domain branded link shortener/redirector easily. It turns a simple json file like this:
{
"gourav": "https://gourav.sh",
"home": "https://github.com/gouravkhunger/directrix"
}
to a rebranded link redirection website. Try these out:
Best for links that you want to rebrand under your own domain (for free). go.example.com/xyz
and link.example.com/product
are various ways links are generally rebranded.
This API lets you create such links effortlessly. I personally use it to host redirects for links on my portfolio site.
This Express.js API can be hosted anywhere node is supported.To setup this API completely for free, I would suggest you to use Deta.
Once you create an account at Deta, you will need to create a new micro. Run these commands in your terminal in order:
curl -fsSL https://get.deta.dev/cli.sh | sh
# for windows: iwr https://get.deta.dev/cli.ps1 -useb | iex
deta new --node micro_name # name also doesn't matter much
To begin with deploying the API, you will need your Deta Access token. Please go to your profile and create one before proceeding.
- Press the green "Use this template" button to create a copy of this project under your profile:
- Go to the Project Settings of this newly created repo.
From the sidebar, navigate to Secrets
> Actions
> New repository secret
. Enter the Name
of the secret and DETA_TOKEN
and paste the access token to the Secret
field.
- Edit the
deploy.yml
file under.github/workflows/
folder to update the project and micro name you have on your Deta dashboard.
Save the changes by pressing "Commit changes".
- Edit the
links.json
file and define however many routes you want.
Each route should's value should be a valid internet link (unless you want errors of course). These will automatically become routes and have redirection logic implemented.
Save the changes by pressing "Commit changes":
- The GitHub Action will deploy the API automatically.
Once it is completed, you will see a green checkmark next to the latest commit on the repo. Head over to Deta Dashboard, choose the micro you created and there you will be able to setup a custom domain for your API.
That's it. Enjoy!
MIT License
Copyright (c) 2022 Gourav Khunger
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.