apeman-api-format

Fomatter API for apeman


Keywords
apeman, api
License
MIT
Install
npm install apeman-api-format@1.0.4

Documentation

apeman-api-format

Build Status Code Climate Code Coverage npm Version JS Standard

Fomatter API for apeman

Installation

$ npm install apeman-api-format --save

Usage

Define a module in Apemanfile and run the server.

/** Example of Apemanfile.js */

'use strict'

const co = require('co')

let { NODE_ENV } = process.env

module.exports = {
  $cwd: __dirname,
  $pkg: { /* ... */ },
  $proto: [ /* ... */ ],
  $api: {
    // Define APIs
    'format': require('apeman-api-format')({
      logging: NODE_ENV === 'development'
    })
  }
}

Then, call the module from client script

#!/usr/bin/env node

/**
 * Example client
 */
'use strict'

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

co(function * () {
  // Setup an client
  let api = yield apemanApiClient('/api')

  // Connect to a module
  let format = yield api.connect('format')
  let pong = yield format.ping()
  /* ... */

  // Format json files
  yield format.formatJson('**/*.json', {
    cwd: 'db/seeds',
    sort: true
  })
})

Methods

The following methods are provided by the API.

.ping(pong)

Test the reachability of the api.

Param Type Description
pong string Pong message to return

.formatJson(pattern, options)

Format json files.

Param Type Description
pattern string Glob filename patterns
options Object Optional settings

.formatJs(pattern, options)

Format js files.

Param Type Description
pattern string Filename pattern
options Object Optional settings

License

This software is released under the MIT License.

Links