Skip to content

Commit 3dad0d2

Browse files
committed
Remove server stuff
Signed-off-by: Fabio José <[email protected]>
1 parent 46dd705 commit 3dad0d2

File tree

3 files changed

+1
-246
lines changed

3 files changed

+1
-246
lines changed

README.md

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -174,37 +174,10 @@ See how to listen to events using
174174
[express](https://github.com/expressjs/express).
175175

176176
```js
177-
177+
var Unmarshaller02 = require("cloudevents-sdk/http/unmarshaller/v02");
178178

179179
```
180180

181-
#### Receiving Using our Simple HTTP Server
182-
183-
See how to listen to events using out simple http server.
184-
185-
```js
186-
var Cloudevent = require("cloudevents-sdk");
187-
188-
// The binding configuration
189-
var config = {
190-
path : "/events",
191-
port : 10300,
192-
method : "POST"
193-
};
194-
195-
// The binding instance
196-
var binding = new Cloudevent.bindings["http-structured0.2"](config);
197-
198-
binding.listen()
199-
.then(cloudevent => {
200-
// do something with event
201-
})
202-
.catch(err => {
203-
// deal with errors
204-
console.error(err);
205-
});
206-
```
207-
208181
## Repository Structure
209182

210183
```text
@@ -357,27 +330,6 @@ Receiver.check(Object, Map)
357330
Cloudevent Receiver.parse(Object, Map)
358331
```
359332

360-
##### Receiver Binding Server
361-
362-
Use this API to start a HTTP server and listen to events.
363-
364-
```js
365-
/*
366-
* The constructor must receives the map of configurations.
367-
*/
368-
Receiver(config)
369-
370-
/*
371-
* Listen to events and returns a Promise.
372-
*/
373-
Promise Receiver.listen()
374-
375-
/*
376-
* Stops the listen to events
377-
*/
378-
Receiver.stop()
379-
```
380-
381333
### `Unmarshaller` classes
382334

383335
The Unmarshaller classes uses the receiver API, abstracting the formats:

lib/bindings/http/server/structured_0_2.js

Lines changed: 0 additions & 102 deletions
This file was deleted.

test/http_binding_0_2.js

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
var expect = require("chai").expect;
22
var Cloudevent = require("../index.js");
33
var nock = require("nock");
4-
var ReceiverStructured01 =
5-
require("../lib/bindings/http/server/structured_0_2.js");
64
var http = require("http");
75
var request = require("request");
86
var Spec02 = require("../lib/specs/spec_0_2.js");
@@ -81,99 +79,6 @@ describe("HTTP Transport Binding - Version 0.2", () => {
8179
});
8280
});
8381
});
84-
85-
describe("Receiver", () => {
86-
var receiver;
87-
before(() => {
88-
// setup
89-
receiver = new ReceiverStructured01(receiverConfig);
90-
receiver.listen()
91-
.then(response => {
92-
console.log(response);
93-
})
94-
.catch(err => {
95-
console.error(err);
96-
});
97-
});
98-
99-
after(() => {
100-
receiver.stop();
101-
});
102-
103-
it("Should return 404 when path is wrong", () => {
104-
// act
105-
request.post("http://localhost:" + receiverConfig.port + "/foobar",
106-
(err, res, body) => {
107-
// assert
108-
expect(res.statusCode).to.equal(404);
109-
});
110-
});
111-
112-
it("Should return 405 when method is wrong", () => {
113-
// act
114-
request.get("http://localhost:" + receiverConfig.port
115-
+ receiverConfig.path,
116-
(err, res, body) => {
117-
// assert
118-
expect(res.statusCode).to.equal(405);
119-
});
120-
});
121-
122-
it("Should return 400 when Content-Type is wrong", () => {
123-
// act
124-
request.post("http://localhost:" + receiverConfig.port
125-
+ receiverConfig.path,
126-
(err, res, body) => {
127-
// assert
128-
expect(res.statusCode).to.equal(400);
129-
});
130-
});
131-
132-
it("Should return 400 when is not a cloudevent", () => {
133-
// setup
134-
var requestOptions = {
135-
url : "http://localhost:" + receiverConfig.port
136-
+ receiverConfig.path,
137-
method : "POST",
138-
headers : {
139-
"Content-Type":"application/cloudevents+json; charset=utf-8"
140-
},
141-
body : JSON.stringify({"foo": "bar"})
142-
};
143-
144-
// act
145-
request(requestOptions,
146-
(err, res, body) => {
147-
// assert
148-
expect(res.statusCode).to.equal(400);
149-
});
150-
});
151-
152-
it("Should return 201 when accepts the event", () => {
153-
// setup
154-
var ce_spec02 = new Spec02();
155-
ce_spec02
156-
.type(type)
157-
.source(source);
158-
159-
var requestOptions = {
160-
url : "http://localhost:" + receiverConfig.port
161-
+ receiverConfig.path,
162-
method : "POST",
163-
headers : {
164-
"Content-Type":"application/cloudevents+json; charset=utf-8"
165-
},
166-
body : JSON.stringify(ce_spec02.payload)
167-
};
168-
169-
// act
170-
request(requestOptions,
171-
(err, res, body) => {
172-
// assert
173-
expect(res.statusCode).to.equal(201);
174-
});
175-
});
176-
});
17782
});
17883

17984
describe("Binary", () => {

0 commit comments

Comments
 (0)