restql 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017 Ariel de Jesús Díaz Sánchez
3
+ Copyright (c) 2017 Ariel Díaz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,14 +4,11 @@ RESTful API Resolver for Nested-Linked Resources | 🕸 🕷
4
4
 
5
5
  ---
6
6
 
7
- [![npm](https://img.shields.io/npm/v/restql.svg?style=flat-square)](https://www.npmjs.com/package/restql/)
8
- [![build](https://img.shields.io/travis/relztic/restql/master.svg?style=flat-square)](https://travis-ci.org/relztic/restql/)
9
- [![maintainability](https://img.shields.io/codeclimate/maintainability/relztic/restql.svg?style=flat-square)](https://codeclimate.com/github/relztic/restql/maintainability/)
10
- [![coverage](https://img.shields.io/codeclimate/c/relztic/restql.svg?style=flat-square)](https://codeclimate.com/github/relztic/restql/test_coverage/)
11
- [![code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier/)
12
-
13
- RestQL allows you to dynamically resolve the nested-linked resources of a RESTful API.
7
+ [![npm](https://img.shields.io/npm/v/restql.svg?style=for-the-badge)](https://www.npmjs.com/package/restql/)
8
+ ![JavaScript](https://img.shields.io/badge/-JavaScript-F0DB4F?style=for-the-badge&logo=typescript&logoColor=black)
9
+ ![Prettier](https://img.shields.io/badge/-Prettier-FF69B4?style=for-the-badge&logo=prettier&logoColor=white)
14
10
 
11
+ RestQL allows you to dynamically resolve the nested-linked resources of a RESTful API.
15
12
  By specifying a set of properties to describe the paths.
16
13
 
17
14
  ## Installation
@@ -19,13 +16,7 @@ By specifying a set of properties to describe the paths.
19
16
  ### npm
20
17
 
21
18
  ```sh
22
- npm install restql --save
23
- ```
24
-
25
- ### Yarn
26
-
27
- ```sh
28
- yarn add restql
19
+ npm install restql
29
20
  ```
30
21
 
31
22
  ### CDN
@@ -34,44 +25,36 @@ yarn add restql
34
25
  <script src="https://unpkg.com/restql/dist/umd/index.min.js"></script>
35
26
  ```
36
27
 
37
- ## Parameters
38
-
39
- ### `resource`
28
+ ## Usage
40
29
 
41
- `{string} The resource to fetch.`
30
+ ### `restql(resource, resolver[, options])`
42
31
 
43
- **Description**
32
+ #### Parameters
44
33
 
45
- Self-explanatory.
34
+ - `resource` (`string`): The resource to fetch.
35
+ - Self-explanatory.
46
36
 
47
- **e.g.:**
37
+ ##### Example
48
38
 
49
39
  ```js
50
40
  'https://pokeapi.co/api/v2/pokemon/1/'
51
41
  ```
52
42
 
53
- ### `resolver`
54
-
55
- `{Object} The resolver to apply.`
43
+ - `resolver` (`Object`): The resolver to apply.
44
+ - At every level, each property describes a path to the nested resources within the current one.
45
+ - RestQL resolves the sames and call the subsequent resolver against them.
46
+ - Until the base case (`null`) is reached; from which it returns back the merged responses.
56
47
 
57
- **Description**
58
-
59
- At each level, each property describes a path to the nested resources within the current one.
60
-
61
- RestQL resolves the sames and call the subsequent resolver against them...
62
-
63
- Until the base case (`null`) is reached; from which it returns back the merged responses.
64
-
65
- **Quantifiers**
48
+ ##### Quantifiers
66
49
 
67
50
  Following is a table of the quantifiers you can use:
68
51
 
69
- | Quantifier | Description |
70
- | --- | --- |
71
- | `[]` | Collection of properties. |
72
- | `?` | Optional property. |
52
+ | Quantifier | Description |
53
+ | ---------- | ------------------------- |
54
+ | `[]` | Collection of properties. |
55
+ | `?` | Optional property. |
73
56
 
74
- **e.g.:**
57
+ ##### Example
75
58
 
76
59
  ```js
77
60
  {
@@ -88,75 +71,33 @@ Following is a table of the quantifiers you can use:
88
71
  }
89
72
  ```
90
73
 
91
- ### `[options]`
74
+ - `[options]` (`Object`): The options to bypass.
75
+ - [See `RequestInit`](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
92
76
 
93
- `{Object} The options to bypass.`
94
-
95
- **Description**
96
-
97
- [`Request Config`](https://github.com/axios/axios/#request-config)
98
-
99
- **e.g.:**
77
+ ##### Example
100
78
 
101
79
  ```js
102
- {
103
- // ...
104
- }
80
+ { ... }
105
81
  ```
106
82
 
107
- ## Usage
83
+ #### Returns
108
84
 
109
- ```js
110
- // External Packages
111
- import restql from 'restql'
112
-
113
- /**
114
- * @constant {string} resource The resource to fetch.
115
- */
116
- const resource = 'https://pokeapi.co/api/v2/pokemon/1/'
117
-
118
- /**
119
- * @constant {Object} resolver The resolver to apply.
120
- */
121
- const resolver = {
122
- 'abilities[]?.ability.url': {
123
- 'generation.url': {
124
- 'main_region.url': null,
125
- },
126
- },
127
- 'stats[].stat.url?': {
128
- 'affecting_natures.increase[].url': null,
129
- 'affecting_natures.decrease[].url': null,
130
- },
131
- 'moves[].move?.url': null,
132
- }
85
+ (`Promise<Object>`): A promise which resolves into an object.
133
86
 
134
- /**
135
- * @constant {Object} options The options to bypass.
136
- */
137
- const options = {
138
- // ...
139
- };
140
-
141
- (async () => {
142
- try {
143
- const data = await restql(resource, resolver, options)
144
-
145
- console.log(data)
146
- } catch (error) {
147
- console.error(error.message)
148
- }
149
- })()
87
+ ## Try It
88
+
89
+ ```sh
90
+ npm run playground
150
91
  ```
151
92
 
152
- [Test RestQL in your browser.](https://npm.runkit.com/restql/)
93
+ [See Playground](https://github.com/relztic/restql/blob/main/playground/index.js)
153
94
 
154
95
  ## Roadmap
155
96
 
156
- - ~~Support for authentication~~
157
- - ~~Support for optional resolvers~~
158
- - ~~Improve package bundler~~
159
- - ~~Ability to cache responses~~
160
- - Support for recursive resolvers
97
+ - ~~Support for authentication~~
98
+ - ~~Support for optional resolvers~~
99
+ - ~~Improve package bundler~~
100
+ - ~~Ability to cache responses~~
101
+ - Support for recursive resolvers
161
102
 
162
- Take 🍰, Folks! 🌮 🐴 💨
103
+ > Take 🎂, Folks! 🌮 🐴 💨