8000 GitHub - camalot/shortnr
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

camalot/shortnr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node ES6 URL Shortener

Stack

Introduction

This is a fork of murraco/node-url-shortener, with massive changes to fit my needs. It is mongodb backed, versus mysql, and entirely REST based. There is no frontend views.

What's a URL Shortener?

URL shortening is a technique to convert a long URL (site or page address) to a shorter version. This shorter version of the URL is usually cleaner and easier to share or remember. When someone accesses the shortened address, the browser redirects to the original (large) url address. It is also called URL redirection or URL redirect.

http://en.wikipedia.org/wiki/URL_shortening

API ENDPOINTS

AUTHENTICATION

Important

If env.NUS_TOKEN_REQUIRED is true then headers['x-access-token'] MUST contain a token that exists in mongodb.shortener.tokens

HEALTH

The health endpoint.

METHOD ENDPOINT DESCRIPTION AUTHENTICATION
GET /health The health endpoint false

SHORTEN

Note

Authentication only required if env.NUS_TOKEN_REQUIRED == true

METHOD ENDPOINT DESCRIPTION AUTHENTICATION
POST /api/shorten Shorten a URL true?

SHORTEN PAYLOAD

{
  "url": "https://google.com/"
}

SHORTEN RESPONSE

Note

https://s.hort.er/ is an example domain. I do not know if it exists, or if it is even a TLD that is available

{
    "id": "5Un9Yv", // the short id
    "target": "https://google.com/", // the short target
    "url": "https://s.hort.er/5Un9Yv", // the short redirect endpoint 
    "urls": [ // array of redirect endpoints
        "https://s.hort.er/5Un9Yv",
        "https://s.hort.er/g/5Un9Yv",
        "https://s.hort.er/go/5Un9Yv"
    ],
    "new": false // indicates if this short was created with this request, or if it already existed.
}

REDIRECT

METHOD ENDPOINT DESCRIPTION AUTHENTICATION
GET /:id Redirect to the original URL false
GET /g/:id Redirect to the original URL false
GET /go/:id Redirect to the original URL false

REDIRECT PAYLOAD

null

REDIRECT RESPONSE

res.redirect(target, 301);

STATS

Note

Authentication only required if env.NUS_TOKEN_REQUIRED == true

METHOD ENDPOINT DESCRIPTION AUTHENTICATION
GET /api/stats/:hash Get statistics of the shortened URL true?

STATS PAYLOAD

null

Note

Token endpoints are only available if env.NUS_ENABLE_TOKEN_CREATE == true

TOKEN CREATE

METHOD ENDPOINT DESCRIPTION AUTHENTICATION
POST /api/token/ Create a new token false

TOKEN CREATE PAYLOAD

{
  "name": "My CLI Token"
}

TOKEN CREATE RESPONSE

{
  "id": "66ac00909a84987ad753ab0d",
  "name": "My CLI Token",
  "token": "kRuCYY9WArKYxhBo9HbJQfFGoiNhd4EdNK6w"
}

TOKEN DESTROY

Note

Authentication ALWAYS Required

METHOD ENDPOINT DESCRIPTION AUTHENTICATION
DELETE /api/token/:id Delete an existing token true

TOKEN DESTROY PAYLOAD

null

About

No description, website, or topics provided.
< 8E85 h3 class="sr-only">Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •  
0