A modern, minimalist, and lightweight URL shortener using Node.js and Redis
JavaScript HTML CSS
Switch branches/tags
Latest commit 14ce271 Nov 28, 2016 @dotzero committed on GitHub Merge pull request #9 from matteocontrini/feature/db-option
add redis-db option
Permalink
Failed to load latest commit information.
config added redis-db option Nov 27, 2016
lib added redis-db option Nov 27, 2016
public Add clipboard.js support Jun 6, 2016
routes Update errors page May 25, 2016
test Add get api to test May 24, 2016
views Add clipboard.js support Jun 6, 2016
.editorconfig .editorconfig May 23, 2016
.gitignore Update dependencies May 22, 2016
.travis.yml Add .travis.yml May 22, 2016
LICENSE Update LICENSE May 22, 2016
README.md added redis-db option Nov 27, 2016
app.js Hide x-powered-by header May 24, 2016
package.json Bump git 0.8.1 Nov 13, 2016

README.md

Node Url Shortener

A modern, minimalist, and lightweight URL shortener using Node.js and Redis.

Build Status GitHub tag Dependency Status

Using

Quick Start

$ git clone https://github.com/dotzero/node-url-shortener nus
$ cd nus
$ npm install
$ node app

Command Line Options

$ node app -h

Usage: app [options]

Options:
  -u, --url     Application URL               [default: "http://127.0.0.1:3000"]
  -p, --port    Port number for the Express application          [default: 3000]
  --redis-host  Redis Server hostname                     [default: "localhost"]
  --redis-port  Redis Server port number                         [default: 6379]
  --redis-pass  Redis Server password                           [default: false]
  --redis-db    Redis DB index                                      [default: 0]
  -h, --help    Show help                                              [boolean]

Installation on production

$ git clone https://github.com/dotzero/node-url-shortener nus
$ cd nus
$ npm install --production
$ NODE_ENV=production node app --url "http://example.com"

RESTful API

POST /api/v1/shorten with form data long_url=http://google.com

{
  "hash": "rnRu",
  "long_url": "http://google.com",
  "short_url": "http://127.0.0.1:3000/rnRu",
  "status_code": 200,
  "status_txt": "OK"
}

GET /api/v1/expand/:hash with query rnRu

{
  "clicks": "1",
  "hash": "rnRu",
  "long_url": "http://google.com",
  "status_code": 200,
  "status_txt": "OK"
}

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

License

Released under the MIT license