# @axelspringer/mango-api

> An API Gateway for WordPress

Latest version **1.0.0-beta.121** (published 2018-09-26) · MIT license · 0 weekly downloads

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

## Install

```sh
npm install @axelspringer/mango-api
pnpm add @axelspringer/mango-api
yarn add @axelspringer/mango-api
bun add @axelspringer/mango-api
```

Provides the command `mango-api`.

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.121 |
| Published | 2018-09-26 |
| First published | 2017-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.9.13 |
| Dependencies | 25 |
| Unpacked size | 226.6 KB |
| Known vulnerabilities | 0 (+25 in 2 direct dependencies) |
| Install scripts | no |
| Author | Axel Springer SE |
| Maintainers | 1250c69, andreasprang, hammi85, jan.michalowsky, jonas_arkulpa, katallaxie, preventdefault, timmsusa, tonimedina |

## Links

- npm: https://www.npmjs.com/package/@axelspringer/mango-api
- npm.io page: https://npm.io/package/@axelspringer/mango-api

## Dependencies (25)

- [koa](https://npm.io/package/koa.md) ^2.5.2
- [axios](https://npm.io/package/axios.md) ^0.18.0
- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [tslib](https://npm.io/package/tslib.md) ^1.9.2
- [yargs](https://npm.io/package/yargs.md) ^12.0.1
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.2
- [ts-node](https://npm.io/package/ts-node.md) ^7.0.0
- [winston](https://npm.io/package/winston.md) ^3.0.0
- [dnscache](https://npm.io/package/dnscache.md) ^1.0.1
- [@koa/cors](https://npm.io/package/@koa/cors.md) ^2.2.1
- [js-sha256](https://npm.io/package/js-sha256.md) ^0.9.0
- [lru-cache](https://npm.io/package/lru-cache.md) ^4.1.3
- [url-parse](https://npm.io/package/url-parse.md) ^1.4.1
- [dataloader](https://npm.io/package/dataloader.md) ^1.3.0
- [koa-router](https://npm.io/package/koa-router.md) ^7.3.0
- [axios-retry](https://npm.io/package/axios-retry.md) ^3.1.1
- [encoding-down](https://npm.io/package/encoding-down.md) ^5.0.4
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.26.0
- [koa-bodyparser](https://npm.io/package/koa-bodyparser.md) ^4.2.1
- [axios-debug-log](https://npm.io/package/axios-debug-log.md) ^0.4.0
- [koa-pino-logger](https://npm.io/package/koa-pino-logger.md) ^2.1.1
- [apollo-server-koa](https://npm.io/package/apollo-server-koa.md) ^2.0.0-rc.8
- [http-status-codes](https://npm.io/package/http-status-codes.md) ^1.3.0
- [regenerator-runtime](https://npm.io/package/regenerator-runtime.md) ^0.12.0
- [http-graceful-shutdown](https://npm.io/package/http-graceful-shutdown.md) ^2.1.1

## Recent versions

- 1.0.0-beta.121 (latest) — 2018-09-26
- 1.0.0-alpha.53 (alpha) — 2018-05-25
- 1.0.0-beta.120 — 2018-09-26
- 1.0.0-beta.119 — 2018-09-26
- 1.1.0-9 — 2018-08-28
- 1.1.0-8 — 2018-08-23
- 1.1.0-7 — 2018-08-22
- 1.1.0-6 — 2018-08-21
- 1.1.0-5 — 2018-08-21
- 1.1.0-4 — 2018-08-13
- 1.1.0-3 — 2018-08-13
- 1.1.0-2 — 2018-08-13
- 1.1.0-1 — 2018-08-13
- 1.1.0-0 — 2018-08-13
- 1.0.0-beta.116 — 2018-07-30
- … 256 more at https://npm.io/package/@axelspringer/mango-api/versions

## README

# :smiley_cat: Mango API

<br/>

[![Taylor Swift](https://img.shields.io/badge/secured%20by-taylor%20swift-brightgreen.svg)](https://twitter.com/SwiftOnSecurity)
[![Volkswagen](https://auchenberg.github.io/volkswagen/volkswargen_ci.svg?v=1)](https://github.com/auchenberg/volkswagen)
[![TypeScript](https://badges.frapsoft.com/typescript/awesome/typescript.png?v=101)](https://github.com/ellerbrock/typescript-badges/)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)

## Getting Started

> requires a `node` version >= 6 and an `npm` version >= 3.x.x

> we use [Koa](https://github.com/koajs/koa) as middleware

> we do provide a `help` command to display all possible arguments

```bash
# Installs the Mango API
npm i @axelspringer/mango-api -g

# Starts the Mango API in Mock modus
mango-api -d
```

## Arguments

> most command line arguments have a reflection in environment variables, which allows it to be easily tested and developed in many environments

### `help`

Displays all the available arguments

### `-wp` `MANGO_WP` (string)

Sets the url to the [WordPress REST](https://developer.wordpress.org/rest-api/) endpoint (e.g. http://localhost/wp-json/)

### `-m` `MANGO_MOCK` (boolean)

Enables the Mocks of the Mango API. 

### `-p` `MANGO_PORT` (string)

Sets the port of the Mango API.

### `-h` `MANGO_HOST` (string)

Sets the host of the Mango API.

### `-t` `MANGO_TOKEN` (string)

Sets the `X-MANGO-TOKEN` to the value provided by [WP Mango](https://github.com/axelspringer/wp-mango).

### `-s` `MANGO_SECRET` (string)

Sets the `X-MANGO-SECRET` to the value provided by [WP Mango](https://github.com/axelspringer/wp-mango).

### `-a` `MANGO_MOCK_ADAPTER` (string)

Uses a differen adapter for the mock data. This should implement and overload.

### `--plugin` `MANGO_PLUGINS` (string)

Loads an installed plugin (e.g. mango-plugin-pagemanager). If used multiple times, it loads multiple plugins. `MANGO_PLUGINS` should be used as follows `export MANGO_PLUGINS='pagemanager,navigation'`.

```javascript
const api = require('@axelspringer/mango-api');

function mocks(axios, config) {
  let adapter = new api.MockAdapter(axios, config);
  adapter.get(api.WP.Posts, require('./data/posts.json')).reply(200);
  adapter.get(api.WP.Users, require('./data/users.json')).reply(200);
  adapter.get(api.WP.NavLocations, require('./data/navLocations.json'), true).reply(200);
  adapter.get(api.WP.NavLocations + '/', require('./data/navLocations.json')).reply(200);
  adapter.get(api.WP.NavMenu, require('./data/navMenus.json')).reply(200);
  adapter.get(api.WP.NavItems, require('./data/navItems.json')).reply(200);
  adapter.get(api.WP.Settings, require('./data/settings.json')).reply(200);
}

exports.default = mocks
```

## Development

> all commands can be seen via `npm run help`

```bash
# Clone the repository
git clone https://github.com/axelspringer/mango

# enter directory
cd mango/packages/api

# Start the local dev server
npm start

# To use your local version for development of other mango parts, run
npm link
```

Have fun!

## License
[MIT](/LICENSE)

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