apeman-app-json
Version:
apeman app to serve dynamic json.
149 lines (102 loc) • 3.8 kB
Markdown
apeman-app-json
==========
<!---
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]
[bd_repo_url]: https://github.com/apeman-app-labo/apeman-app-json
[bd_travis_url]: http://travis-ci.org/apeman-app-labo/apeman-app-json
[bd_travis_shield_url]: http://img.shields.io/travis/apeman-app-labo/apeman-app-json.svg?style=flat
[bd_license_url]: https://github.com/apeman-app-labo/apeman-app-json/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/apeman-app-labo/apeman-app-json
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/apeman-app-labo/apeman-app-json.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/apeman-app-labo/apeman-app-json.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/apeman-app-labo/apeman-app-json
[bd_gemnasium_shield_url]: https://gemnasium.com/apeman-app-labo/apeman-app-json.svg
[bd_npm_url]: http://www.npmjs.org/package/apeman-app-json
[bd_npm_shield_url]: http://img.shields.io/npm/v/apeman-app-json.svg?style=flat
[bd_bower_badge_url]: https://img.shields.io/bower/v/apeman-app-json.svg?style=flat
<!-- Badge End -->
<!-- Description Start -->
<a name="description"></a>
apeman app to serve dynamic json.
<!-- Description End -->
<!-- Overview Start -->
<a name="overview"></a>
Define `res.json()` method to send json data in response.
<!-- Overview End -->
<!-- Sections Start -->
<a name="sections"></a>
<!-- Section from "doc/readme/01.Installation.md.hbs" Start -->
<a name="section-doc-readme-01-installation-md"></a>
Installation
-----
```bash
$ npm install apeman-app-json --save
```
<!-- Section from "doc/readme/01.Installation.md.hbs" End -->
<!-- Section from "doc/readme/02.Usage.md.hbs" Start -->
<a name="section-doc-readme-02-usage-md"></a>
Usage
---------
1. Define an app within Apemanfile.js
2. Call the app via apeman app command.
**Apemanfile.js**
```javascript
/** This example Apemanfile to use apeman-app-json */
"use strict";
module.exports = {
$pkg: {/*...*/},
$apps: {
// Define your own app.
'my-app-01': {
// Map url and handlers.
'/': [
require('apeman-app-json')({
//Options
}),
function(req, res, next){
// `res.json()` method is available now.
res.json({
success:true
})
}
]
}
}
};
```
Then,
```bash
$ apeman app my-app-01 -p 3000
```
<!-- Section from "doc/readme/02.Usage.md.hbs" End -->
<!-- Section from "doc/readme/03.Options.md.hbs" Start -->
<a name="section-doc-readme-03-options-md"></a>
Options
-------
| Key | Type | Default | Description |
| --- | ---- | --- | --- |
| spaces | number | 2 | JSON spaces |
| contentType | string | 'application/json; charset=UTF-8;' | Content type for header |
| name | string | 'json' | Property name of response to set the function. |
<!-- Section from "doc/readme/03.Options.md.hbs" End -->
<!-- Sections Start -->
<!-- LICENSE Start -->
<a name="license"></a>
License
-------
This software is released under the [MIT License](https://github.com/apeman-app-labo/apeman-app-json/blob/master/LICENSE).
<!-- LICENSE End -->
<!-- Links Start -->
<a name="links"></a>
Links
------
+ [apeman](https://github.com/apeman-labo/apeman)
+ [apeman-app](https://github.com/apeman-labo/apeman-app)
<!-- Links End -->