Skip to content
Create tinyurl/redirection service with ease.
JavaScript
Branch: master
Clone or download
dependabot-preview and amio Bump tap from 14.6.4 to 14.6.9 (#69)
Bumps [tap](https://github.com/tapjs/node-tap) from 14.6.4 to 14.6.9.
- [Release notes](https://github.com/tapjs/node-tap/releases)
- [Commits](tapjs/node-tap@v14.6.4...v14.6.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
1
Latest commit ba55bb3 Oct 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Create config.yml May 27, 2018
bin Add port options for cli May 15, 2018
example upgrade to now v2 Jan 29, 2019
test Fix test Mar 20, 2019
.gitignore Bump tap to 14.2.3 Jun 16, 2019
.npmignore upgrade to now v2 Jan 29, 2019
.travis.yml Update to node 10 in .travis.yml Apr 26, 2018
LICENSE (chore) docs cleanup May 17, 2018
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 Bump tap from 14.6.4 to 14.6.9 (#69) Oct 4, 2019
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.