From 25c4ad27f7690ab0f8b538f177edc12429bf30ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Sun, 9 Jun 2019 20:58:44 -0300 Subject: [PATCH] Docs for parser, fix project structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- README.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a2aa8c8..d2e5c32 100644 --- a/README.md +++ b/README.md @@ -185,11 +185,13 @@ binding.receive() ```text ├── index.js +├── ext ├── lib │   ├── bindings │   │   └── http │   ├── cloudevent.js -│   ├── format +│   ├── formats +│   │   └── json │   └── specs ├── LICENSE ├── package.json @@ -197,10 +199,11 @@ binding.receive() ``` - `index.js`: library exports +- `ext`: external stuff, e.g, Cloud Events JSONSchema - `lib/bindings`: every binding implementation goes here - `lib/bindings/http`: every http binding implementation goes here - `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 ## Unit Testing @@ -209,7 +212,6 @@ The unit test checks the result of formatted payload and the constraints. ```bash npm test - ``` ## 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. */ -Object Formatter.format(payload) +Object Formatter.format(Object) /* * 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 @@ -272,8 +284,8 @@ Spec.check() * @throws Error when it is an invalid event */ Spec.check(Object) - ``` + ### `Binding` classes Every Binding class must implement these methods to work properly.