1 | apeman-app-json
|
2 | ==========
|
3 |
|
4 |
|
5 | This file is generated by ape-tmpl. Do not update manually.
|
6 | --->
|
7 |
|
8 |
|
9 | <a name="badges"></a>
|
10 |
|
11 | [![Build Status][bd_travis_shield_url]][bd_travis_url]
|
12 | [![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
|
13 | [![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
|
14 | [![npm Version][bd_npm_shield_url]][bd_npm_url]
|
15 | [![JS Standard][bd_standard_shield_url]][bd_standard_url]
|
16 |
|
17 | [bd_repo_url]: https://github.com/apeman-app-labo/apeman-app-json
|
18 | [bd_travis_url]: http://travis-ci.org/apeman-app-labo/apeman-app-json
|
19 | [bd_travis_shield_url]: http://img.shields.io/travis/apeman-app-labo/apeman-app-json.svg?style=flat
|
20 | [bd_license_url]: https://github.com/apeman-app-labo/apeman-app-json/blob/master/LICENSE
|
21 | [bd_codeclimate_url]: http://codeclimate.com/github/apeman-app-labo/apeman-app-json
|
22 | [bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/apeman-app-labo/apeman-app-json.svg?style=flat
|
23 | [bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/apeman-app-labo/apeman-app-json.svg?style=flat
|
24 | [bd_gemnasium_url]: https://gemnasium.com/apeman-app-labo/apeman-app-json
|
25 | [bd_gemnasium_shield_url]: https://gemnasium.com/apeman-app-labo/apeman-app-json.svg
|
26 | [bd_npm_url]: http://www.npmjs.org/package/apeman-app-json
|
27 | [bd_npm_shield_url]: http://img.shields.io/npm/v/apeman-app-json.svg?style=flat
|
28 | [bd_standard_url]: http://standardjs.com/
|
29 | [bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | <a name="description"></a>
|
36 |
|
37 | apeman app to serve dynamic json.
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | <a name="overview"></a>
|
44 |
|
45 |
|
46 | Define `res.json()` method to send json data in response.
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | <a name="sections"></a>
|
53 |
|
54 |
|
55 |
|
56 | <a name="section-doc-guides-01-installation-md"></a>
|
57 | Installation
|
58 | -----
|
59 |
|
60 | ```bash
|
61 | $ npm install apeman-app-json --save
|
62 | ```
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | <a name="section-doc-guides-02-usage-md"></a>
|
70 | Usage
|
71 | ---------
|
72 |
|
73 | 1. Define an app within Apemanfile.js
|
74 | 2. Call the app via apeman app command.
|
75 |
|
76 | **Apemanfile.js**
|
77 | ```javascript
|
78 | /** This is an example Apemanfile to use apeman-app-json */
|
79 |
|
80 | 'use strict'
|
81 |
|
82 | module.exports = {
|
83 | $pkg: { /* ... */ },
|
84 | $apps: {
|
85 | // Define your own app.
|
86 | 'my-app-01': {
|
87 | // Map url and handlers.
|
88 | '/': [
|
89 | require('apeman-app-json')({
|
90 | // Options
|
91 | }),
|
92 | (req, res, next) => {
|
93 | // `res.json()` method is available now.
|
94 | res.json({
|
95 | success: true
|
96 | })
|
97 | }
|
98 | ]
|
99 | }
|
100 | }
|
101 | };
|
102 | ```
|
103 |
|
104 | Then,
|
105 | ```bash
|
106 | $ apeman app my-app-01 -p 3000
|
107 | ```
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | <a name="section-doc-guides-03-signature-md"></a>
|
115 | Signature
|
116 | -------
|
117 |
|
118 | #### apemanAppJson(options) -> function
|
119 |
|
120 |
|
121 |
|
122 | ##### Args
|
123 |
|
124 | | Name | Type | Default | Description |
|
125 | | --- | ---- | --- | --- |
|
126 | | options | object | | Optional settings. |
|
127 | | options.spaces | number | 2 | JSON spaces |
|
128 | | options.contentType | string | 'application/json charset | Content type for header |
|
129 | | options.name | string | json | Property name of response to set the function. |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | <a name="license"></a>
|
140 |
|
141 | License
|
142 | -------
|
143 | This software is released under the [MIT License](https://github.com/apeman-app-labo/apeman-app-json/blob/master/LICENSE).
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 | <a name="links"></a>
|
150 |
|
151 | Links
|
152 | ------
|
153 |
|
154 | + [apeman](https://github.com/apeman-labo/apeman)
|
155 | + [apeman-app](https://github.com/apeman-labo/apeman-app)
|
156 |
|
157 |
|