# apeman-api

> Remote api call

Latest version **1.0.22** (published 2016-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install apeman-api
pnpm add apeman-api
yarn add apeman-api
bun add apeman-api
```

Provides the command `apeman-api`.

## 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.22 |
| Published | 2016-10-02 |
| First published | 2016-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Taka Okunishi |
| Maintainers | okunishinishi |
| Keywords | apeman, command |

## Links

- npm: https://www.npmjs.com/package/apeman-api
- Repository: https://github.com/apeman-cmd-labo/apeman-api
- Homepage: https://github.com/apeman-cmd-labo/apeman-api#readme
- Issues: https://github.com/apeman-cmd-labo/apeman-api/issues
- npm.io page: https://npm.io/package/apeman-api

## Dependencies (9)

- [co](https://npm.io/package/co.md) ^4.6.0
- [aport](https://npm.io/package/aport.md) ^1.0.0
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [rfunc](https://npm.io/package/rfunc.md) ^2.1.1
- [aslogger](https://npm.io/package/aslogger.md) ^1.0.2
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [apemanfile](https://npm.io/package/apemanfile.md) ^8.0.0
- [stringcase](https://npm.io/package/stringcase.md) ^3.0.1
- [apeman-api-client](https://npm.io/package/apeman-api-client.md) ^1.1.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.22 (latest) — 2016-10-02
- 1.0.21 — 2016-08-31
- 1.0.20 — 2016-08-21
- 1.0.19 — 2016-08-13
- 1.0.18 — 2016-08-07
- 1.0.17 — 2016-08-03
- 1.0.16 — 2016-08-01
- 1.0.15 — 2016-07-30
- 1.0.14 — 2016-07-30
- 1.0.13 — 2016-07-27
- 1.0.12 — 2016-07-24
- 1.0.11 — 2016-07-23
- 1.0.10 — 2016-07-16
- 1.0.9 — 2016-07-12
- 1.0.8 — 2016-07-12
- … 8 more at https://npm.io/package/apeman-api/versions

## README

apeman-api
==========

<!---
This file is generated by ape-tmpl. Do not update manually.
--->

<!-- Badge Start -->
<a name="badges"></a>

[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
[![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[![JS Standard][bd_standard_shield_url]][bd_standard_url]

[bd_repo_url]: https://github.com/apeman-cmd-labo/apeman-api
[bd_travis_url]: http://travis-ci.org/apeman-cmd-labo/apeman-api
[bd_travis_shield_url]: http://img.shields.io/travis/apeman-cmd-labo/apeman-api.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/apeman-cmd-labo/apeman-api
[bd_travis_com_shield_url]: https://api.travis-ci.com/apeman-cmd-labo/apeman-api.svg?token=
[bd_license_url]: https://github.com/apeman-cmd-labo/apeman-api/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/apeman-cmd-labo/apeman-api
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/apeman-cmd-labo/apeman-api.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/apeman-cmd-labo/apeman-api.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/apeman-cmd-labo/apeman-api
[bd_gemnasium_shield_url]: https://gemnasium.com/apeman-cmd-labo/apeman-api.svg
[bd_npm_url]: http://www.npmjs.org/package/apeman-api
[bd_npm_shield_url]: http://img.shields.io/npm/v/apeman-api.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg

<!-- Badge End -->


<!-- Description Start -->
<a name="description"></a>

Remote api call

<!-- Description End -->


<!-- Overview Start -->
<a name="overview"></a>



<!-- Overview End -->


<!-- Sections Start -->
<a name="sections"></a>

<!-- Section from "doc/guides/01.Installation.md.hbs" Start -->

<a name="section-doc-guides-01-installation-md"></a>

Installation
-----

Install apeman-api module via [npm][npm_url].
```bash
$ npm install apeman-api -g
```


[npm_url]: https://www.npmjs.com/


<!-- Section from "doc/guides/01.Installation.md.hbs" End -->

<!-- Section from "doc/guides/02.Usage.md.hbs" Start -->

<a name="section-doc-guides-02-usage-md"></a>

Usage
---------

1. Prepare an Apemanfile.js at your project root.
2. Run the command via CLI.

***Apemanfile.js***
```javascript
/** Example of Apemanfile.js */

'use strict'

const co = require('co')

module.exports = {
  $cwd: __dirname,
  $pkg: { /* ... */ },
  $proto: [ /* ... */ ],
  $api: {
    // Define APIs
    'sign': {
      signin (username, password) {
        return co(function * () { // Returns a promise
          /* ... */
          return { success: true }
        })
      },
      signout () {
        /* ... */
      }
    }
  }
}

```

Then, start the server with command

```bash
$ apeman-api
```

**Client Script**
```javascript
#!/usr/bin/env

'use strict'

const apemanApiClient = require('apeman-api/client')
const co = require('co')

co(function * () {
  let api = apemanApiClient('http://localhost:3000')

  {
    // Access to sign api
    let sign = yield api.connect('sign')
    // Call defined method with promise interface.
    let { success } = yield sign.signin('my-account', 'a9!ladsf0')
    /* ... */
  }
}).catch((err) => console.error(err))

```

##### CLI Options

```bash
$ apeman-api -h

  Usage: apeman-api [options] 

  Remote api call

  Options:

    -h, --help                           output usage information
    -V, --version                        output the version number
    -p, --port <port>                    Port number
    -c, --configuration <configuration>  Pathname of Apemanfile

  Examples:

  $ apeman-api -p 3000   # Start apeman api server


```


<!-- Section from "doc/guides/02.Usage.md.hbs" End -->

<!-- Section from "doc/guides/03.Programmatic API.md.hbs" Start -->

<a name="section-doc-guides-03-programmatic-a-p-i-md"></a>

Programmatic API
---

apeman-api also provide programmatic API.

Firstly, install the module locally.

```bash
$ npm install apeman-api --save-dev
```

Then,

```javascript
#!/usr/bin/env

'use strict'

const apemanApi = require('apeman-demo-api')
const co = require('co')

co(function * () {
  yield apemanApi({})
}).catch((err) => console.error(err))

```


##### Programmatic Options

| Key | Description | Default |
| --- | ----------- | ------- |
| port | Port number |  |
| configuration | Pathname of Apemanfile |  |


<!-- Section from "doc/guides/03.Programmatic API.md.hbs" End -->

<!-- Section from "doc/guides/04.Advanced Usage.md.hbs" Start -->

<a name="section-doc-guides-04-advanced-usage-md"></a>

Advanced Usage
---------

This is a more advance example of apeman api.

Names starts with `$` and `@` has special meaning and not treated as api module.

***Apemanfile.js***
```javascript
/** Example of Apemanfile.js */

'use strict'

const co = require('co')

module.exports = {
  $cwd: __dirname,
  $pkg: { /* ... */ },
  $proto: [ /* ... */ ],
  get $api () {
    const sign = require('apeman-api-sign')
    const session = require('apeman-api-middleware-session')
    const debug = require('debug')('my-project:api')
    const { db } = this.$ctx
    return {
      // Define APIs
      'sign': sign(),
      // Called before method invocation
      $before () {
        const s = this
        let { module, method, params } = s.state.invocation
        debug(`${module}.${method} with params: ${params}`)
      },
      // Called after method invocation
      $after () {
        let s = this
        let { module, method, returns } = s.state.invocation
        debug(`${module}.${method} with returns: ${returns}`)
      },
      // Koa middlewares
      $middlewares: [
        session(db.models.Session)
      ],
      // You can define custom scope with `@` prefix
      '@admin': {
        user: {
          destroy (id) { /* ... */ }
        }
      }
    }
  }
}

```


<!-- Section from "doc/guides/04.Advanced Usage.md.hbs" End -->


<!-- Sections Start -->


<!-- LICENSE Start -->
<a name="license"></a>

License
-------
This software is released under the [MIT License](https://github.com/apeman-cmd-labo/apeman-api/blob/master/LICENSE).

<!-- LICENSE End -->


<!-- Links Start -->
<a name="links"></a>

Links
------

+ [apeman][apeman_url]
+ [apeman-cmd-labo][apeman_cmd_labo_url]

[apeman_url]: http://github.com/apeman-labo/apeman
[apeman_cmd_labo_url]: http://github.com/apeman-cmd-labo

<!-- Links End -->

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