Skip to content

MiniGod/now-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

now-go npm-version

A personal tinyurl service.


Now go, let the legend come back to life!

Features

  • Lightweight tinyurl service (in 100 lines).
  • Semi-auto update with a remote config.
  • Three types of routes:
    • redirect to an url
    • echo a string
    • proxy tunnel
  • Deploy to now.sh with one command.

Quick Start

  • cli

    npm i -g now-go
    now-go -c path/to/config.json
    
  • programaticly

    import nowgo from 'now-go'
    nowgo('./config.json')
  • deploy to now.sh

    now -e NOW_GO_CONFIG=http://example.com/config.json amio/now-go
    now alias https://now-go-ab78a901.now.sh/ short.example.com
    

    If you don't have now yet, npm install -g now. Don't miss this awesome tool for realtime global deployments.

The config.json Example

All configurations are optional:

{
  "routes": {
    // redirection (<value> is a url)
    "home": "https://github.com/amio/now-go",
    // proxy mode (<value> is a url prefixed with "PROXY >> ")
    "ocelot.jpg": "PROXY >> https://example.com/path-to-ocelog.jpg",
    // echo a string (<value> is a string)
    "now-go": "Now go, let the legend come back to life!",

    // special route for root path (<key> === "/")
    "/": "Yet another tinyurl service.",
    // special route for unmatched path: (<key> === "?")
    "?": "What are you looking for?"
  },
  "port": 3030 // optional, 3000 by default
}

This is the config for http://go.now.sh.

Remote Config

  • Instead of now-go -c config.json, start server with:
    now-go -c https://example.com/path-to-config.json
    
    or:
    NOW_GO_CONFIG=https://example.com/path-to-config.json now-go
    

NOTE: Visit root path(the sepcial route "/") will trigger an update task in background -- so called "semi-auto update" :)

License

MIT © Amio

About

Create & Deploy a personal tinyurl service in 1 minute.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%