Create tinyurl/redirection service with ease.
Now go, let the legend come back to life!
- Lightweight tinyurl service (~50 sloc).
- Three types of routes:
URL
: redirect to an urlTEXT
: echo a stringFUNCTION
: acceptsreq
argument, returnsURL
/TEXT
routes
- Deploy to now.sh with one command.
-
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
-
create http handler
const http = require('http') const { createHandler } = require('now-go') const config = require('./path/to/config.json') const handler = createHandler(config) http.createServer(handler).listen(3000)
{
// 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."
}
// redirect everything to new-example.com
module.exports = {
"*": (req) => `https://new-example.com${req.url}`
}
- https://go.now.sh and it's index.js