Sunday, January 1, 2017

NodeJs URL shortener


Run your individual URL shortening provider, or combine one into your current NodeJs servers.

this is a natural server-facet module. URL shortify

README.md

A NodeJs server that allows you to run an easy URL shortening server.

Features

  • Person can publish a whole URL and obtain a short URL
  • Whilst vacationing a brief URL, user will get redirected to the long URL
  • If same URL is shortened more than one occasions, the fast URL gets re-used
  • Extraordinarily speedy shortening and extending
    • Specifics for the algorithms nerds:
      • O(1) time complexity for each insert and lookup
      • O(N) house complexity
  • Simply extended, designed with flexibility in mind
    • No dependence on frameworks, corresponding to express
    • As An Alternative exposes a low level NodeJs HTTP maintain serve as, which can be ate up by way of such a lot NodeJs frameworks
    • Each And Every characteristic is split into its personal handler function, in case you wish to combine and fit on your personal
  • Easy and versatile templating
    • Out of the field strengthen for Jade templates
      • Simply positioned them in jade-templates/, they usually shall be automatically compiled
      • Simply require web page-templates.js, and this module exports template functions whose names match the Jade files
    • this is utterly optional, and you can use your own preferred engine

putting in place

First, install some prerequisites:

  • NodeJs and npm.
    • you wish to use NodeJs >= v0.10.29 && < v0.11.x
    • Follow directions here.
  • Redis.
    • you should use Redis >= v2.8.16 && < v3.0.x
    • Apply directions right here.
    • On Ubuntu/ Debian programs, after make, set up Redis as a carrier:
      • cd utils && sudo ./install_server.sh
  • OpenSSL.
    • should be preloaded on most systems, another way, follow directions right here.
    • Run openssl record-message-digest-algorithms and ensure that MD5 is out there

Next, within the folder where you've this module installed, run:

npm install node run get started

Lastly, seek advice from http://0.0.0.0:8080/ to your browser, and also you need to be caused with the principle web page, the place you can shorten your first URL.

Advanced usage

Say you already have your individual NodeJs server, and also you do not want to replace it with this one, but moderately simply care for a few further routes for URL shortening. that is for sure possible.

cp urlshortify $EXISTING_PROJECT/node_modules/ #edit $EXISTING_PROJECT/package.json to include "urlshortify" in dependencies

Notice that because this module is personal, because it needs to be dispensed using Envato’s market. it is no longer allotted the use of npm. npm set up --store urlshortify will no longer paintings. Thus you want to install it manually using the steps above.

For all features

If you wish to include all features, you can use the primary handler serve as by means of requiring it:

var urlshortify = require('urlshortify');

Use server.js as a reference.

For person features

Then Again, you'll use the individual handler functions, if you want to compose your routes with a higher level of specificity:

var urlshortifyLengthen = require('urlshortify').lengthen;

Configuration

Edit config-settings.js to switch the settings to your URL shortener. The settings are explained inline in comments.

whilst you get started the server, test the console output. it'll print out a the configuration item, similar to:

config hostname: '10.1.1.1', port: '8080', isDebug: true, hashIdSalt: 'hashids salt', minLength: 6, startingCounter: 0, assumeProtocol: 'http'

it's strongly really useful that when you installation the app to production, you ought to amendment your hostname to the domain that you are deploying to, the port to 80, and the hash salt to one thing as opposed to the default price. The default values for the other configuration settings could also be left as is for manufacturing.

Word that after deployed to manufacturing, you desire to never amendment the worth of the hash salt, unless you might be willing to invalidate all URLs that have been shortened past.

Issues/ Requests

Please let me know in the Comments phase for this merchandise.

Licence

This module is accessible twin licenced underneath

  • the Envato Regular Licence dated 30 April 2014
  • the Envato Prolonged Licence dated 30 April 2014

As such, this module is no longer available from the npm registry. as opposed to npm installing this, you need to replica the folder to the right area.

Please purchase the common licence if you want to make use of this in a single application for a single consumer, and purchase the prolonged licence if you want to make use of this in multiple packages or for more than one clients. Learn the entire details of the licences from the pages above.

Author

Brendan Graetz

  • bguiz.com
  • @bguiz
 
FULL DOWNLOAD

No comments:

Post a Comment

Trik tersembunyi Bermain Slither.io agar menjadi no 1 | cara tau ampuh

Slither.io Unblocked Play Engaging in online game playing avails a chance for one to have a great experience. This opens up an enormous amo...