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 =const config = // routes 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.jsmoduleexports = // stright routes "/": "https://example.com" "/hi": "Hello there!" // functional route `This leads to nowhere.`