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.
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
Important
If env.NUS_TOKEN_REQUIRED
is true
then headers['x-access-token']
MUST contain a token that exists in mongodb.shortener.tokens
The health endpoint.
METHOD | ENDPOINT | DESCRIPTION | AUTHENTICATION |
---|---|---|---|
GET |
/health |
The health endpoint | false |
Note
Authentication only required if env.NUS_TOKEN_REQUIRED == true
METHOD | ENDPOINT | DESCRIPTION | AUTHENTICATION |
---|---|---|---|
POST |
/api/shorten |
Shorten a URL | true? |
{
"url": "https://google.com/"
}
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
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 |
null
res.redirect(target, 301);
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? |
null
Note
Token
endpoints are only available if env.NUS_ENABLE_TOKEN_CREATE == true
METHOD | ENDPOINT | DESCRIPTION | AUTHENTICATION |
---|---|---|---|
POST |
/api/token/ |
Create a new token | false |
{
"name": "My CLI Token"
}
{
"id": "66ac00909a84987ad753ab0d",
"name": "My CLI Token",
"token": "kRuCYY9WArKYxhBo9HbJQfFGoiNhd4EdNK6w"
}
Note
Authentication ALWAYS Required
METHOD | ENDPOINT | DESCRIPTION | AUTHENTICATION |
---|---|---|---|
DELETE |
/api/token/:id |
Delete an existing token | true |
null