npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

now-go

2.0.0 • Public • Published

now-go npm-version

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 = require('now-go')
    const config = require('./path/to/config.json') // routes config
     
    go(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.js
module.exports = {
  // stright routes
  "/": "https://example.com",
  "/hi": "Hello there!",
 
  // functional route
  "*": (req) => `This ${req.url} leads to nowhere.`
}

License

MIT © Amio

Keywords

none

install

npm i now-go

Downloadsweekly downloads

2

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability