Docs for parser, fix project structure
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
0f9fadb718
commit
25c4ad27f7
24
README.md
24
README.md
|
@ -185,11 +185,13 @@ binding.receive()
|
||||||
|
|
||||||
```text
|
```text
|
||||||
├── index.js
|
├── index.js
|
||||||
|
├── ext
|
||||||
├── lib
|
├── lib
|
||||||
│ ├── bindings
|
│ ├── bindings
|
||||||
│ │ └── http
|
│ │ └── http
|
||||||
│ ├── cloudevent.js
|
│ ├── cloudevent.js
|
||||||
│ ├── format
|
│ ├── formats
|
||||||
|
│ │ └── json
|
||||||
│ └── specs
|
│ └── specs
|
||||||
├── LICENSE
|
├── LICENSE
|
||||||
├── package.json
|
├── package.json
|
||||||
|
@ -197,10 +199,11 @@ binding.receive()
|
||||||
```
|
```
|
||||||
|
|
||||||
- `index.js`: library exports
|
- `index.js`: library exports
|
||||||
|
- `ext`: external stuff, e.g, Cloud Events JSONSchema
|
||||||
- `lib/bindings`: every binding implementation goes here
|
- `lib/bindings`: every binding implementation goes here
|
||||||
- `lib/bindings/http`: every http binding implementation goes here
|
- `lib/bindings/http`: every http binding implementation goes here
|
||||||
- `lib/cloudevent.js`: implementation of Cloudevent, an interface
|
- `lib/cloudevent.js`: implementation of Cloudevent, an interface
|
||||||
- `lib/format/`: every format implementation goes here
|
- `lib/formats/`: every format implementation goes here
|
||||||
- `lib/specs/`: every spec implementation goes here
|
- `lib/specs/`: every spec implementation goes here
|
||||||
|
|
||||||
## Unit Testing
|
## Unit Testing
|
||||||
|
@ -209,7 +212,6 @@ The unit test checks the result of formatted payload and the constraints.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## The API
|
## The API
|
||||||
|
@ -242,13 +244,23 @@ Every formatter class must implement these methods to work properly.
|
||||||
/*
|
/*
|
||||||
* Format the Cloudevent payload argument and return an Object.
|
* Format the Cloudevent payload argument and return an Object.
|
||||||
*/
|
*/
|
||||||
Object Formatter.format(payload)
|
Object Formatter.format(Object)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Format the Cloudevent payload as String.
|
* Format the Cloudevent payload as String.
|
||||||
*/
|
*/
|
||||||
String Formatter.toString(payload)
|
String Formatter.toString(Object)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `Parser` classes
|
||||||
|
|
||||||
|
Every formatter class must implement these methods to work properly.
|
||||||
|
|
||||||
|
```js
|
||||||
|
/*
|
||||||
|
* Try to parse the payload to some event format
|
||||||
|
*/
|
||||||
|
Object Parser.parse(payload)
|
||||||
```
|
```
|
||||||
|
|
||||||
## `Spec` classes
|
## `Spec` classes
|
||||||
|
@ -272,8 +284,8 @@ Spec.check()
|
||||||
* @throws Error when it is an invalid event
|
* @throws Error when it is an invalid event
|
||||||
*/
|
*/
|
||||||
Spec.check(Object)
|
Spec.check(Object)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### `Binding` classes
|
### `Binding` classes
|
||||||
|
|
||||||
Every Binding class must implement these methods to work properly.
|
Every Binding class must implement these methods to work properly.
|
||||||
|
|
Loading…
Reference in New Issue