Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use HTTP bindings correctly #579

Merged
merged 33 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
044823a
initial commit
KhudaDad414 Oct 20, 2023
62b7076
initial commit
KhudaDad414 Oct 25, 2023
2b40e2f
Merge remote-tracking branch 'upstream/master' into v3-playground
KhudaDad414 Oct 26, 2023
1ada3d4
initial draft
KhudaDad414 Oct 30, 2023
839c82c
Merge branch 'v3-playground' into request-reply
KhudaDad414 Oct 30, 2023
8b97e96
use better names for channels and operations
KhudaDad414 Nov 1, 2023
224391c
add readme
KhudaDad414 Nov 3, 2023
a498823
update readme
KhudaDad414 Nov 3, 2023
ac4c281
re-enable send
KhudaDad414 Nov 6, 2023
8c3f8f9
Merge branch 'master' into request-reply
KhudaDad414 Nov 8, 2023
37c929e
Merge branch 'master' into request-reply
KhudaDad414 Nov 8, 2023
a7cca8b
refactor
KhudaDad414 Nov 9, 2023
b214597
add tests
KhudaDad414 Nov 9, 2023
8b3000c
remove warnings
KhudaDad414 Nov 10, 2023
202176f
Update src/adapters/http/client.ts
KhudaDad414 Nov 15, 2023
494d8a7
Update src/lib/adapter.ts
KhudaDad414 Nov 15, 2023
73e2030
Update src/lib/functions.ts
KhudaDad414 Nov 15, 2023
02555cb
Update src/lib/functions.ts
KhudaDad414 Nov 15, 2023
8e5a1a1
Update src/lib/functions.ts
KhudaDad414 Nov 15, 2023
e585f17
final touches
KhudaDad414 Nov 15, 2023
9e99f90
modify reply generation
KhudaDad414 Nov 15, 2023
983a9a9
refactor
KhudaDad414 Nov 16, 2023
3b42bb2
merge changes
KhudaDad414 Nov 16, 2023
77c6739
add diferent HTTP test methods
KhudaDad414 Nov 17, 2023
c383d35
fix reply checking logic
KhudaDad414 Nov 17, 2023
bd13259
fix client and servers
KhudaDad414 Nov 17, 2023
4b296c1
fix stash
KhudaDad414 Nov 17, 2023
609a783
final changes.
KhudaDad414 Nov 21, 2023
e3faa13
add readme.
KhudaDad414 Nov 21, 2023
3691cff
merge branch master into http-bindings
KhudaDad414 Nov 21, 2023
b3b1c68
check method
KhudaDad414 Nov 21, 2023
8cada26
revert unwanted changes
KhudaDad414 Nov 21, 2023
606c9d0
fix error
KhudaDad414 Nov 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/http-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# HTTP Test Project

## Overview
This project is a test suite for evaluating the HTTP server functionality in the Glee framework. It sets up an HTTP server on port 3000, and upon receiving a POST request, it sends multiple test requests to `https://httpbin.org/` to verify the operational aspects of the server.


### Installation
1. Navigate to the project directory:
```sh
cd examples/http-test
```
3. Install the necessary Node.js packages:
```sh
npm install
```

### Running the Server
1. Start the HTTP server by running:
```sh
npm run dev
```
2. The server will start on `http://localhost:3000`.

### Testing the Server
Send a POST request to `http://localhost:3000` using a tool like cURL or Postman. The server, upon receiving the request, will initiate several test requests to `https://httpbin.org/` and validate the functionality.
139 changes: 139 additions & 0 deletions examples/http-test/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
asyncapi: 3.0.0
info:
title: Test HTTP in glee using httpbin.org
version: 1.0.0
description: This app is a test app. it will send requests to httpbin.org to see if glee works well with http protocol.
servers:
httpbin.org:
host: 'httpbin.org'
protocol: https
local-trigger:
host: 'localhost:3000'
protocol: http
channels:
TRIGGER:
address: /
servers:
- $ref: '#/servers/local-trigger'
messages:
string:
$ref: "#/components/messages/string"
empty:
$ref: "#/components/messages/empty"
DELETE:
address: /delete
servers:
- $ref: '#/servers/httpbin.org'
GET:
address: /get
servers:
- $ref: '#/servers/httpbin.org'
POST:
address: /post
servers:
- $ref: '#/servers/httpbin.org'
PATCH:
address: /patch
servers:
- $ref: '#/servers/httpbin.org'
PUT:
address: /put
servers:
- $ref: '#/servers/httpbin.org'
operations:
sendTrigger:
action: send
channel:
$ref: "#/channels/TRIGGER"
messages:
- $ref: "#/components/messages/string"
receiveTrigger:
reply:
channel:
$ref: "#/channels/TRIGGER"
messages:
- $ref: "#/components/messages/string"
channel:
$ref: '#/channels/TRIGGER'
action: receive
bindings:
http:
method: POST
sendDELETE:
channel:
$ref: '#/channels/DELETE'
action: send
bindings:
http:
method: DELETE
receiveDELETE:
channel:
$ref: '#/channels/DELETE'
action: receive
sendGET:
channel:
$ref: '#/channels/GET'
action: send
bindings:
http:
method: GET
receiveGET:
channel:
$ref: '#/channels/GET'
action: receive
bindings:
http:
method: GET
sendPOST:
channel:
$ref: '#/channels/POST'
action: send
bindings:
http:
method: POST
receivePOST:
channel:
$ref: '#/channels/POST'
action: receive
sendPATCH:
channel:
$ref: '#/channels/PATCH'
action: send
bindings:
http:
method: PATCH
receivePATCH:
channel:
$ref: '#/channels/PATCH'
action: receive
sendPUT:
channel:
$ref: '#/channels/PUT'
action: send
bindings:
http:
method: PUT
receivePUT:
channel:
$ref: '#/channels/PUT'
action: receive
components:
messages:
string:
bindings:
http:
headers:
type: object
required: ["a", "b"]
properties:
a:
type: string
b:
type: string
payload:
type: string
empty:
payload:
type: "null"
x-remoteServers:
KhudaDad414 marked this conversation as resolved.
Show resolved Hide resolved
- httpbin.org
28 changes: 28 additions & 0 deletions examples/http-test/docs/asyncapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Test HTTP in glee using httpbin.org 1.0.0 documentation

This app is a test app. it will send requests to httpbin.org to see if glee works well with http protocol.

## Table of Contents

* [Servers](#servers)
* [httpbin.org](#httpbinorg-server)
* [local-trigger](#local-trigger-server)

## Servers

### `httpbin.org` Server

* URL: `https://httpbin.org/`
* Protocol: `https`



### `local-trigger` Server

* URL: `http://localhost:3000/`
* Protocol: `http`



## Operations

8 changes: 8 additions & 0 deletions examples/http-test/functions/receiveDELETE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default async function ({ payload }) {
if (!payload.url) {
console.error("DELETE receive failed.")
return
}

console.log("DELETE operation succeded..")
}
8 changes: 8 additions & 0 deletions examples/http-test/functions/receiveGET.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default async function ({ payload }) {
if (!payload.url) {
console.error("GET receive failed.")
return
}

console.log("GET operation succeded..")
}
8 changes: 8 additions & 0 deletions examples/http-test/functions/receivePATCH.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default async function ({ payload }) {
if (!payload.url) {
console.error("PATCH receive failed.")
return
}

console.log("PATCH operation succeded..")
}
7 changes: 7 additions & 0 deletions examples/http-test/functions/receivePOST.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default async function ({ payload }) {
if (!payload.url) {
console.error("POST receive failed.")
return
}
console.log("POST operation succeded..")
}
8 changes: 8 additions & 0 deletions examples/http-test/functions/receivePUT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default async function ({ payload }) {
if (!payload.url) {
console.error("PUT receive failed.")
return
}

console.log("PUT operation succeded..")
}
30 changes: 30 additions & 0 deletions examples/http-test/functions/receiveTrigger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export default async function (event) {

Check warning on line 1 in examples/http-test/functions/receiveTrigger.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

'event' is defined but never used

Check warning on line 1 in examples/http-test/functions/receiveTrigger.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - macos-latest

'event' is defined but never used
const server = 'httpbin.org'
return {
reply: [{
payload: "You have successfully triggered the test server..."
}],
send: [
{
server,
channel: "DELETE"
},
{
server,
channel: "GET"
},
{
server,
channel: "POST"
},
{
server,
channel: "PATCH"
},
{
server,
channel: "PUT"
}
],
}
}
Loading