# marauders-map

> service port announcer and finder

Latest version **0.2.3** (published 2013-02-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install marauders-map
pnpm add marauders-map
yarn add marauders-map
bun add marauders-map
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2013-02-28 |
| First published | 2012-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sérgio Ramos |
| Maintainers | ramitos |
| Keywords | port, service, announcement, discovery |

## Links

- npm: https://www.npmjs.com/package/marauders-map
- Repository: https://github.com/ramitos/marauders-map
- npm.io page: https://npm.io/package/marauders-map

## Dependencies (6)

- [mdns](https://npm.io/package/mdns.md) 1.1.x
- [clone](https://npm.io/package/clone.md) 0.1.x
- [domain.js](https://npm.io/package/domain.js.md) 0.0.x
- [waterfall](https://npm.io/package/waterfall.md) 0.0.x
- [subdomain.js](https://npm.io/package/subdomain.js.md) 0.0.x
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) 0.0.x

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 0.2.3 (latest) — 2013-02-28
- 0.2.2 — 2012-11-08
- 0.2.1 — 2012-10-31
- 0.2.0 — 2012-10-31
- 0.1.0 — 2012-10-29
- 0.0.7 — 2012-10-19

## README

# marauders map

## usage

###### random process

```js
var reveal = require('marauders-map').reveal,
    http = require('http')

var address = http.createServer(function (req, res) {
  res.end('hello from web')
}).listen().address()

reveal({
  name: 'web', //name of the service
  domain: 'lvh.me', //only accepts requests for the domain 'lvh.me'
  subdomain: 'www', //only accepts requests for the subdomain 'www'
  port: address.port,
  routes: {
    '/:method/:number': [], //accepts all methods for this route
    '/:method': ['put'] //only accepts PUT methods for this route
  }
})
```

###### main process

```js
var seek = require('marauders-map').map(),
    proxy = require('http-proxy'),
    request = require('request')

proxy.createServer(function (req, res, proxy) {
  var node = seek(req)

  proxy.proxyRequest(req, res, {
    host: 'localhost',
    port: node.port
  })
}).listen(1337)

request('http://www.lvh.me:1337/get/5', function (e, res, body) {
  assert(body === 'hello from web')
})
```

*[lvh.me](http://lvh.me) is a domain that points to your local virtual host. nslookup for [lvh.me](http://lvh.me) shows the address as 127.0.0.1* ([http://pivotallabs.com](http://pivotallabs.com/users/apeng/blog/articles/1891-standup-10-14-11-lvh-me))

*[node-proxy](https://github.com/nodejitsu/node-http-proxy) is a full-featured http proxy for node.js*

## install
```bash
npm install marauders-map
```

## test

```bash
npm test
```

## todo

 * improve documentation
 * write examples

## api

### map()

```js
var seek = require('marauders-map').map()
```

Returns a function to seek nodes

### reveal(node)

Node parameters:
 * `name` **required**
 * `port` *optional*
 * `domain` *optional*
 * `subdomain` *optional*
 * `routes` *optional*

### seek(http request)

Return a `node` if finds one

## interoperability

### [turnout](https://github.com/ramitos/turnout)

Only `turnout >= 0.0.5`

```js
var reveal = require('marauders-map').reveal,
    router = require('turnout')(),
    require('http')

var address = http.createServer(function (req, res) {
  router(req, res, function () {
    res.statusCode = 404
    res.end()
  })
}).listen().address()

router.post('/todo/:id', function (req, res, params, query) {})

router.put('/todo/:id/:state', function (req, res, params, query) {})

reveal({
  name: 'todo',
  port: address.port,
  routes: router.routes()
})
```

Even better, with [blage](https://github.com/ramitos/blage)

```js
var reveal = require('marauders-map').reveal,
    router = require('turnout')(),
    blage = require('blage'),
    require('http')

var address = http.createServer(blage(router)).listen().address()

router.post('/todo/:id', function (req, res, params, query) {})
router.put('/todo/:id/:state', function (req, res, params, query) {})

reveal({
  name: 'todo',
  port: address.port,
  routes: router.routes()
})
```

## examples

```json
[
  {
    "name": "a",
    "subdomain": "zmeyyjxusi",
    "port": 8147
  },
  {
    "name": "c",
    "subdomain": "zmeyyjxusi",
    "port": 6078,
    "routes": {
      "/:method/:number": [],
      "/:method": ["put"]
    }
  },
  {
    "name": "d",
    "port": 5237,
    "routes": {
      "/:method/:number": ["get", "post", "delete"],
      "/:method": ["put"]
    }
  },
  {
    "name": "e",
    "port": 3617,
    "routes": {
      "/": []
    }
  },
  {
    "name": "f",
    "port": 9508
  },
  {
    "name": "g",
    "domain": "llvm.me",
    "subdomain": "zmeyyjxusi",
    "port": 81471
  },
  {
    "name": "h",
    "domain": "llvm.me",
    "subdomain": "zmeyyjxusi",
    "port": 80471,
    "routes": {
      "/:method/:number": ["get", "post", "delete"],
      "/:method": ["put"]
    }
  },
  {
    "name": "l",
    "domain": "llvm.me",
    "port": 95081
  }
]
```

## license
MIT

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