Create tinyurl/redirection service with ease.
Create tinyurl/redirection service with ease.
Now go, let the legend come back to life!
URL
: redirect to an urlTEXT
: echo a stringFUNCTION
: accepts req
argument, returns URL
/TEXT
routescli
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)
go-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."
}
go-config.js
// redirect everything to new-example.com
module.exports = {
"*": (req) => `https://new-example.com${req.url}`
}