Code Monkey home page Code Monkey logo

urlshortener's Introduction

urlShortener

A JavaScript URL shortener running in Node.js.

How to set up

Download the folder and open config.json in a text editor.

You can specify the port, the domain you're serving and the path to the create-short-url function.

  1. myPort should be 80 if the app is running on its own server. If it's running behind another server you might want to use another port.

  2. rootDomain is the domain you're allocating URLs from. My domain is pocalyp.se. Your domain will obviously be something else. It must point to this server via DNS using a wildcard so that all sub-domains also point to this server.

  3. createPath is like a password, so it should be something fairly random. If you leave it at its default value anyone who knows your domain will be able to allocate URLs. Maybe this is what you want? If so, leave it as-is.

config.json is also where we store all the data for the server, including the URL mappings, and hit counts, etc.

Open the file in a text editor after launching the server to see the values it initializes. And you can watch it as it the app is running through the /status endpoint.

Source listing

A source listing that preserves the outline structure of the code might be useful for some.

Updates

v0.42 12/19/15 by DW

We maintain a folder of static files, arranged by domain, one for each URL.

The files contain the HTML needed to convert the shortener to a static site. You can drop those folders into the domains folder of PagePark, for example, and point the root domain at the server, it will serve the files.

I added this feature because eventually all servers go away, and when this one does, I want to be able to easily keep the links from breaking.

v0.41 12/16/15 by DW

The home page of each sub-domain is now a JSON listing of all the items posted on that domain.

Questions

Ask on the server-snacks mail list.

urlshortener's People

Contributors

scripting avatar

Watchers

Ali Baitam avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.