Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

surajgoraya/naal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

naal - 🔗 A short-link service

naal ਨਾਲ (nāl) – meaning "with"

What Is it?

Simply put, naal is a self-hosted, short-linking (akin to something like bit.ly) service. It was born out of both curiosity, as well as none of the existing services fitting my relatively simple needs. Would I recommend using this as a large scale prod application? No, pls - I mostly made this to learn :)

How it works

naal uses GitHub as it's storage medium for short-link mappings, as well as using as a means of authentication and management. The server simply looks up the current redirection mapping stored in the repo and upon a request it redirects the user based on the mapping.

Stack

  • Go (Server)
  • Typescript/React (Frontend admin panel)

Set up

.env

  • The .env file stored in the root directory needs to contain the following:
    GITHUB_CLIENTID=
    
    GITHUB_SECRET=
    
    ACCESS_CONTROL=https://api.github.com/repos/{user}/{repoName}
    
    CHECK_URL=https://raw.githubusercontent.com/{user}/{repo}/main/links.json
    
    MODE={prod | debug}
    The GitHub Client ID and Secret can be obtained by creating a new OAuth application in your GitHub settings. Access Control refers to the repo that you want to ensure users have access to so, i.e the repo which contains your links.json file. The check URL is the direct URL to the links.json file which the server will reference when redirecting users. The mode variable is used to change the way redirection works for the admin panel (i.e to a react app running at 3000, or to just the standard app)

naal-admin/src/env.ts

  • Another environment file needs to be added and stored within the admin panel code, signifying if the environment is in development or not (adjusts how the admin panel redirects), as well as the name of the repo which contains the links.json file.
    export const enviroment = {
          "debug": true, //is app in production or not
          "access": "links" //name of the repo containing links.json
      }
    This env.ts file will likely be deprecated, in the future as this is a super inefficient way to manage this.

GitHub OAuth App Settings

  • Callback URL should be set as {Your Hostname}/auth/authenticated

Managing links:

  • This is done through an interface (pictured above) which currently hardcoded to be available at /bossman because I have a dumb sense of humor, although, I suspect I'll make this a variable in the future.

About

🔗 naal (ਨਾਲ [nāl] – meaning "with") is a self-hosted short-link service made using Typescript React and Go!

Resources

Stars

Watchers

Forks

Packages

No packages published