Git Product home page Git Product logo

gogo's Introduction

Requirements

  1. node > v4.0.0
  2. MongoDB

Installation

  1. npm install
  2. npm start
  3. To custom configuration, create file config/local.json. Read more at https://github.com/lorenwest/node-config/wiki/Configuration-Files

Example API request with CURL

List all public URL (GET)

curl http://localhost:8080/api/url

Create short URL (POST)

curl -X POST -d '{"to":"http://opendream.co.th","alias":"opendream","private":false}' http://localhost:8080/api/url --header "Content-Type: application/json"

If private is not specified then default value false will be used.

Sample return JSON

{
  "id": "563f52892ea9df1b6b6bb7a9",
  "to": "http://opendream.co.th",
  "short": "NJpVgrOze",
  "alias": "opendream",
  "passcode": "Y_5cce9M",
  "conditions": [],
  "private": false
}

You need to keep returned id and passcode to update short URL later.

Update short URL (PUT)

curl -X PUT -d '{"to":"http://opendream.co.th","alias":"new-opendream","passcode":"Y_5cce9M"}' http://localhost:8080/api/url/563f52892ea9df1b6b6bb7a9 --header "Content-Type: application/json"

You can only update to, alias and conditions.

Use condition for dynamic destination (PUT)

curl -X PUT -d '{"conditions":[{"expression":"useragent.isMobile","to":"http://m.opendream.co.th"}]}' http://localhost:8080/api/url --header "Content-Type: application/json"

You can use only one provided variable named useragent for now. And for the sake of readability, here is the above JSON.

{
  "conditions": [
    {
      "expression": "useragent.isMobile",
      "to": "http://m.opendream.co.th"
    }
  ]
}

Example condition.expression.useragent

{
  "isMobile": false,
  "isTablet": false,
  "isiPad": false,
  "isiPod": false,
  "isiPhone": false,
  "isAndroid": false,
  "isBlackberry": false,
  "isOpera": false,
  "isIE": false,
  "isEdge": false,
  "isIECompatibilityMode": false,
  "isSafari": false,
  "isFirefox": false,
  "isWebkit": false,
  "isChrome": false,
  "isKonqueror": false,
  "isOmniWeb": false,
  "isSeaMonkey": false,
  "isFlock": false,
  "isAmaya": false,
  "isEpiphany": false,
  "isDesktop": false,
  "isWindows": false,
  "isLinux": false,
  "isLinux64": false,
  "isMac": false,
  "isChromeOS": false,
  "isBada": false,
  "isSamsung": false,
  "isRaspberry": false,
  "isBot": false,
  "isCurl": true,
  "isAndroidTablet": false,
  "isWinJs": false,
  "isKindleFire": false,
  "isSilk": false,
  "silkAccelerated": false,
  "browser": "unknown",
  "os": "Curl",
  "platform": "Curl",
  "geoIp": {},
  "source": "curl/7.43.0"
}

gogo's People

Contributors

noomz avatar

Stargazers

Roman avatar

Watchers

 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.