2.0.0 • Published 7 years ago

now-go v2.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

now-go npm-version

A tinyurl service.

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

2.0.0

7 years ago

2.0.0-0

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago