Skip to content
Create tinyurl/redirection service with ease.
Branch: master
Clone or download
dependabot-preview and amio Bump tap from 14.2.5 to 14.4.1 (#54)
Bumps [tap](https://github.com/tapjs/node-tap) from 14.2.5 to 14.4.1.
- [Release notes](https://github.com/tapjs/node-tap/releases)
- [Commits](tapjs/node-tap@v14.2.5...v14.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
1
Latest commit 6fb36cf Jul 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
bin
example
test Fix test Mar 20, 2019
.gitignore Bump tap to 14.2.3 Jun 16, 2019
.npmignore
.travis.yml Update to node 10 in .travis.yml Apr 26, 2018
LICENSE
README.md Add example for createHandler Jun 16, 2019
index.js add cache header Jan 29, 2019
now.json Update deploy config Mar 20, 2019
ocelot.jpg (chore) docs cleanup May 17, 2018
package-lock.json
package.json Bump tap to 14.2.3 Jun 16, 2019

README.md

now-go npm-version install-size

Create tinyurl/redirection service with ease.


Now go, let the legend come back to life!

Features

  • Lightweight tinyurl service (~50 sloc).
  • Three types of routes:
    • URL: redirect to an url
    • TEXT: echo a string
    • FUNCTION: accepts req argument, returns URL/TEXT routes
  • 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
  • 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)

Example configs

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}`
}

Live Demo

License

MIT © Amio

You can’t perform that action at this time.