Personal tinyurl service.


Keywords
micro, redirect, service, tinyurl, tinyurl-service
License
MIT
Install
npm install now-go@2.0.0

Documentation

now-go npm-version

A tinyurl service.


Now go, let the legend come back to life!

Features

  • Lightweight tinyurl service (in 100 lines).
  • Three types of routes:
    • URL: redirect to an url
    • TEXT: echo a string
    • FUNCTION: return a URL/TEXT by req argument
  • Deploy to now.sh with one command.

Quick Start

  • cli

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

    const go = require('now-go')
    const config = require('./path/to/config.json') // routes config
    
    go(config)  // Start server on port 3000

Example config

content of config.json:

{
  // 302 redirection
  "/": "https://example.com",

  // echo text
  "/tag": "Now go, let the legend come back to life!",

  // "*" is a special route for unmatched path
  "*": "Yet another tinyurl service."
}

or you can use function for more advanced usage, like example.config.js (The config for http://go.now.sh.)

// example.config.js
module.exports = {
  // stright routes
  "/": "https://example.com",
  "/hi": "Hello there!",

  // functional route
  "*": (req) => `This ${req.url} leads to nowhere.`
}

License

MIT © Amio