# ml-proxy

> Proxy code for calling MarkLogic endpoints. Supports using cookies or basic authentication with the MarkLogic REST API.

Latest version **0.1.6** (published 2015-06-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install ml-proxy
pnpm add ml-proxy
yarn add ml-proxy
bun add ml-proxy
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2015-06-06 |
| First published | 2015-05-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ryan Semerau |
| Maintainers | ryan321 |
| Keywords | marklogic |

## Links

- npm: https://www.npmjs.com/package/ml-proxy
- Repository: https://github.com/ryan321/ml-proxy
- Issues: https://github.com/ryan321/ml-proxy/issues
- npm.io page: https://npm.io/package/ml-proxy

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.1.6 (latest) — 2015-06-06
- 0.1.5 — 2015-06-06
- 0.1.4 — 2015-06-04
- 0.1.3 — 2015-06-04
- 0.1.2 — 2015-06-04
- 0.1.0 — 2015-05-29

## README

# ml-proxy
Node proxy code for calling MarkLogic endpoints. Supports using cookies or basic authentication with the MarkLogic REST API.

## Usage
- use `require` to load the module
- call the `init` function to set parameters (authMethod can either be 'cookie' or 'basic')
- call `proxy` object and optionally override:
    - path
    - method
    - params
    - body
    - headers
- optionally provide a response handler callback function
```
var mlProxy = require('ml-proxy');

mlProxy.init({
  mlPort: options.mlPort,
  mlHost: options.mlHost,
  authMethod: 'cookie'
});
var proxy = mlProxy.proxy;

//User log in
app.post('/api/user/login', function(req, res) {
  mlProxy.proxyLogin(req, res, {
    username: req.body.username,
    password: req.body.password
  });
});

//User log out
app.get('/api/user/logout', function(req, res) {
  delete req.session.user;
  mlProxy.proxyLogout(req, res);
});

//Example getting a doc by uri
app.get('/api/get/:uri', function(req, res) {
  var path = '/v1/documents?uri=' + req.params.uri + '&transform=to-json';
  proxy(req, res, {
    path: path
  });
});

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