# shortcode-redirect

> A HTTP shortcode, redirection and tracking server

Latest version **1.0.0** (published 2015-09-01) · 0 weekly downloads

## Install

```sh
npm install shortcode-redirect
pnpm add shortcode-redirect
yarn add shortcode-redirect
bun add shortcode-redirect
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-09-01 |
| First published | 2015-09-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Soren Riise |
| Maintainers | sorenriise |
| Keywords | redirect, 302, server, http, simple, shortcode, tracking |

## Links

- npm: https://www.npmjs.com/package/shortcode-redirect
- Repository: https://github.com/sorenriise/node-redirect
- Homepage: http://sorenriise.github.com/node-redirect
- Issues: https://github.com/sorenriise/node-redirect/issues
- npm.io page: https://npm.io/package/shortcode-redirect

## Dependencies (3)

- [nconf](https://npm.io/package/nconf.md) 0.6.x
- [mongodb](https://npm.io/package/mongodb.md) ^2.0.42
- [log-writer](https://npm.io/package/log-writer.md) 0.0.9

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-09-01

## README

# node-redirect

Creates a server that redirects incoming traffic to another domain and tracks all the requests.

This server allows for a high volume of redirect codes.  Redirect codes are created programatically.


# Requirements

- node
- npm
- mongodb

# Installation

```
    npm install shortcode-redirect
```
You will need to have MongoDb installed as well; shortcodes database is serverd from mongodb


# Configuration

In order to run the `redirect` application, you will need to modify the `config.json` with your redirection options.


```js
{
  "port": 80,
  "redirects": {
    "localhost": {
      "code": 302,
      "lookup": true,
      "insert": {
        "sharedsalt": "my secret salt",
	"url": "/newshortcode"
      }			
    },
    "otherhost.com": {
      "host": "http://shopping.example.com",
      "keepurl": true
      "code": 302,
    },
    "*": {
      "host": "http://www.google.com",
      "code": 302
    }
  }
}
```

The "*" config is the catch all, every host not specified in the config will be redirected there.

The "localhost" entry has two variants;

Varient 1 -- This will take the shortcode from the url and redirect to a personalized url.

- lookup: true/false, translated the short code to a destination url.
- insert: allow the domain to be used for creating new shortcodes remotely.  See example.py how to create and post new shortcodes.
    - sharedsalt: seret used to sign requests.
    - url: the url used for the post operation
- code: the http code used for redirecting traffic.

Vatriant 2 -- A static mapping of one domain to another (i.e. no short codes, but just redirect)

- host: The destination URL
- keepurl: true/false, retrain the url part of the request, i.e. example.com/abc -> google.com/abc


# Usage

### Starting locally

    node bin/server

Create an example shortcode;

    python ./example.py


*Now you can visit http://localhost/... to be redirected*

Or specify a custom port on wich to run the server:

    node bin/server --port=3000

---
_Source: https://npm.io/package/shortcode-redirect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
