-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Fran Mendez <[email protected]>
- Loading branch information
Showing
25 changed files
with
24,680 additions
and
7,586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules | ||
examples/social-network/frontend | ||
examples/crypto-websockets | ||
dist | ||
.glee | ||
test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules | |
.DS_Store | ||
dist | ||
coverage | ||
.vscode | ||
.vscode | ||
.glee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Crypto Websockets | ||
This example tries to showcase how Glee could be used as a WebSocket client. There is a server that streams the price change of a fake cryptocurrency (we can call it asyncapicoin) and the client subscribes to this stream and draws a graph in the terminal. | ||
|
||
<img src="./graph.png"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TOKEN=arb-tokenValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
asyncapi: 2.4.0 | ||
info: | ||
title: asyncapicoin client | ||
version: 1.0.0 | ||
description: | | ||
This app creates a client that subscribes to the server for the price change. | ||
servers: | ||
websockets: | ||
url: ws://localhost:3000 | ||
protocol: ws | ||
x-remoteServers: | ||
- websockets | ||
channels: | ||
/price: | ||
bindings: | ||
ws: | ||
bindingVersion: 0.1.0 | ||
publish: | ||
operationId: index | ||
message: | ||
$ref: '#/components/messages/indexGraph' | ||
components: | ||
messages: | ||
indexGraph: | ||
payload: | ||
type: object | ||
properties: | ||
status: | ||
type: string | ||
time: | ||
type: number | ||
price: | ||
type: number | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"time":1663935946665,"price":130,"status":"started"},{"time":1663935947684,"price":140,"status":"intransit"},{"time":1663935948690,"price":130,"status":"intransit"},{"time":1663935949698,"price":140,"status":"intransit"},{"time":1663935950710,"price":150,"status":"intransit"},{"time":1663935951716,"price":130,"status":"intransit"},{"time":1663935952724,"price":100,"status":"intransit"},{"time":1663935953737,"price":110,"status":"intransit"},{"time":1663935954742,"price":140,"status":"intransit"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import path from 'path' | ||
import fs from 'fs' | ||
import asciichart from 'asciichart' | ||
|
||
export default async function (event) { | ||
const payload = event.payload | ||
const dbPath = path.resolve('./db.json') | ||
const read = () => JSON.parse(fs.readFileSync(dbPath, 'utf-8')) | ||
const write = (data) => { fs.writeFileSync(dbPath, data, { encoding: 'utf-8' }) } | ||
let db | ||
switch (payload.status) { | ||
case 'started': | ||
write(JSON.stringify([payload])) | ||
break | ||
case 'intransit': | ||
db = read() | ||
write(JSON.stringify([...db, payload])) | ||
break | ||
case 'finished': | ||
db = read() | ||
const values = [...db, payload] | ||
console.log(asciichart.plot(values.map(v => v.price), {height: 8})) | ||
} | ||
return { | ||
send: [] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "client", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "glee dev" | ||
}, | ||
"type": "module", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@asyncapi/glee": "file:../../..", | ||
"asciichart": "^1.5.25" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"target": "es6", | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"resolveJsonModule": true, | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
asyncapi: 2.4.0 | ||
info: | ||
title: asyncapicoin server | ||
version: 1.0.0 | ||
description: | | ||
This app is a dummy server that would stream the price of a fake cryptocurrency | ||
servers: | ||
websocket: | ||
url: ws://localhost:3000 | ||
protocol: ws | ||
channels: | ||
/price: | ||
bindings: | ||
ws: | ||
bindingVersion: 0.1.0 | ||
subscribe: | ||
message: | ||
$ref: '#/components/messages/indexGraph' | ||
components: | ||
messages: | ||
indexGraph: | ||
summary: Data required for drawing index graph | ||
payload: | ||
type: object | ||
properties: | ||
status: | ||
type: string | ||
time: | ||
type: number | ||
price: | ||
type: number |
Oops, something went wrong.