pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/lambda2/apiize/commit/2419ad1d2aa1121fabb4d4804d9eddc7fcacb204

console and readme and options · lambda2/apiize@2419ad1 · GitHub
Skip to content

Commit 2419ad1

Browse files
committed
console and readme and options
1 parent ea087ba commit 2419ad1

File tree

6 files changed

+90
-9
lines changed

6 files changed

+90
-9
lines changed

README.md

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,102 @@ $ npm install -g apiize
1212

1313
## Command line usage
1414

15+
- Start a new server on a given JSON file or url
16+
1517
```bash
16-
var apiize = require('apiize');
18+
$ apiize ./test/datasets/punchlines.json
19+
20+
___ _ _
21+
/ _ \ (_|_)
22+
/ /_\ \_ __ _ _ _______
23+
| _ | '_ \| | |_ / _ \
24+
| | | | |_) | | |/ / __/
25+
\_| |_/ .__/|_|_/___\___|
26+
| |
27+
|_|
28+
29+
💫 Express has taken the stage and is listening on port 1313
30+
31+
∙ GET /api/contents Return all the contents
32+
∙ GET /api/contents/:id Return the given contents
33+
∙ GET /api/tags Return all the tags
34+
∙ GET /api/tags/:id Return the given tags
35+
∙ GET /api/authors Return all the authors
36+
∙ GET /api/authors/:id Return the given authors
37+
∙ GET /api/albums Return all the albums
38+
∙ GET /api/albums/:id Return the given albums
39+
∙ GET /api/titles Return all the titles
40+
∙ GET /api/titles/:id Return the given titles
41+
∙ GET /api/ Return all items
42+
∙ GET /api/random A random item
1743
18-
apiize('Rainbow');
1944
```
2045
46+
- Make requests on it
47+
48+
```bash
49+
$ curl -H "Accept: application/json" "localhost:1313/"
50+
51+
{"endpoints":[{"url":"/api/contents","description":"Return all the contents"},{"url":"/api/contents/:id","description":"Return the given contents"},{"url":"/api/tags","description":"Return all the tags"},{"url":"/api/tags/:id","description":"Return the given tags"},{"url":"/api/authors","description":"Return all the authors"},{"url":"/api/authors/:id","description":"Return the given authors"},{"url":"/api/albums","description":"Return all the albums"},{"url":"/api/albums/:id","description":"Return the given albums"},{"url":"/api/titles","description":"Return all the titles"},{"url":"/api/titles/:id","description":"Return the given titles"},{"url":"/api/","description":"Return all items"},{"url":"/api/random","description":"A random item"}]}%
52+
```
2153
2254
## Usage
2355
2456
```js
25-
var apiize = require('apiize');
57+
const Apiize = require('apiize');
58+
59+
// Here is the default options
60+
const options = {
61+
verbose: false, // Output more verbose requests
62+
prefix: 'api', // The root endpoint of the API
63+
port: 1313 // The express server port.
64+
};
65+
66+
// Turn the 'http://example.org/file.json' file into an API
67+
let apiize = new Apiize('http://example.org/file.json', options);
68+
69+
// When apiize is ready
70+
apiize.on('ready', function (server) {
71+
server.serve(); // run the server
72+
});
73+
74+
```
75+
76+
## API
77+
78+
```js
79+
var Apiize = require('apiize');
2680
27-
apiize('Rainbow');
81+
var api = new Apiize(link, options);
2882
```
2983
84+
### Apiize(link, options)
85+
86+
Create a new Apiize object using the given `link` and `options`.
87+
The `link` argument must be a string of a JSON file or a JSON URL.
88+
89+
#### Options
90+
91+
Apiize accepts these properties in the options object.
92+
93+
##### verbose
94+
95+
Defaults to `false`, add a more verbose logging of incoming requests.
96+
97+
- Without `verbose`:
98+
`GET / 200 146 - 6.079 ms`
99+
100+
- With `verbose`:
101+
`::1 - - [25/Jun/2016:15:41:06 +0000] "GET / HTTP/1.1" 200 750 "-" "curl/7.43.0"`
102+
103+
##### prefix
104+
105+
Set the root path of the generated api routes. Defaults to `api`.
106+
107+
##### port
108+
109+
Set the express server port. Defaults to `1313`.
110+
30111
## License
31112
32113
MIT © [Andre Aubin](http://andral.kiwi)

dist/apiize/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var Apiize = (function (_EventEmitter) {
4848

4949
_get(Object.getPrototypeOf(Apiize.prototype), 'constructor', this).call(this);
5050

51-
var defaults = { cache: true, verbose: false };
51+
var defaults = { verbose: false };
5252
this.params = Object.assign(defaults, params);
5353
this.server = undefined;
5454

dist/apiize/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ var Server = (function () {
169169
}, {
170170
key: 'hello',
171171
value: function hello() {
172-
console.log('\n ___ _ _ \n / _ \\ (_|_) \n/ /_\\ \\_ __ _ _ _______ \n| _ | \'_ \\| | |_ / _ \\\n| | | | |_) | | |/ / __/\n\\_| |_/ .__/|_|_/___\\___|\n | | \n |_| \n '.blue);
172+
console.log('\n ___ _ _ \n / _ \\ (_|_) \n/ /_\\ \\_ __ _ _ _______ \n| _ | \'_ \\| | |_ / _ \\\n| | | | |_) | | |/ / __/\n\\_| |_/ .__/|_|_/___\\___|\n | | \n |_| \n '.rainbow);
173173
console.log('💫 ' + (' Express has taken the stage and is listening on port ' + this.params.port + '\n').green);
174174
var _iteratorNormalCompletion3 = true;
175175
var _didIteratorError3 = false;

lib/apiize/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Apiize extends EventEmitter {
1414
constructor(data, params = {}) {
1515
super();
1616

17-
const defaults = {cache: true, verbose: false};
17+
const defaults = {verbose: false};
1818
this.params = Object.assign(defaults, params);
1919
this.server = undefined;
2020

lib/apiize/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Server {
100100

101101
// Say hello and print routes
102102
hello() {
103-
console.log(`\n ___ _ _ \n / _ \\ (_|_) \n/ /_\\ \\_ __ _ _ _______ \n| _ | '_ \\| | |_ / _ \\\n| | | | |_) | | |/ / __/\n\\_| |_/ .__/|_|_/___\\___|\n | | \n |_| \n `.blue);
103+
console.log(`\n ___ _ _ \n / _ \\ (_|_) \n/ /_\\ \\_ __ _ _ _______ \n| _ | '_ \\| | |_ / _ \\\n| | | | |_) | | |/ / __/\n\\_| |_/ .__/|_|_/___\\___|\n | | \n |_| \n `.rainbow);
104104
console.log('💫 ' + ` Express has taken the stage and is listening on port ${this.params.port}\n`.green);
105105
for (const route of this.routes) {
106106
let info = route.info ? ` ${route.info}`.grey : '';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apiize",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Turn any json file into a full, explorable, REST API",
55
"homepage": "",
66
"author": {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy