-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aeb82b3
commit fa9c913
Showing
8 changed files
with
210 additions
and
6 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
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,14 @@ | ||
{ | ||
"admin": true, | ||
"admin_password": "password", | ||
"admin_secret": "secret", | ||
"debug": true, | ||
"anonymous": true, | ||
"v3_use_offset": true, | ||
"token_hmac_secret_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJpYXQiOjE1ODk0NDI3Mjh9.fN_KOKH2yOc1Fp2QcMaYd2z8-LxVTg7My1kSBLMUrPs", | ||
"prometheus": true, | ||
"graphite": true, | ||
"graphite_host": "localhost", | ||
"graphite_port": 2003, | ||
"token_hmac_secret_key": "shhhhh", | ||
"api_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJpYXQiOjE1ODk0NDI3ODh9.03oCkrDVT_HGMsEaIsu1q2JsSRGq5rayk-WbXhRcvtY" | ||
} |
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,6 +1,9 @@ | ||
import jwt from 'jsonwebtoken'; | ||
|
||
const secretKey = 'shhhhh'; | ||
const token = jwt.sign({ foo: 'bar', subject: '' }, 'shhhhh'); | ||
console.log('secretKey', secretKey); | ||
console.log('token', token); | ||
|
||
|
||
const token = jwt.sign({ foo: 'bar' }, 'shhhhh'); | ||
console.log(token); | ||
const decoded = jwt.verify(token, secretKey); | ||
console.log('decoded', decoded); |
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
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 @@ | ||
import readline from 'readline'; | ||
import axios from 'axios'; | ||
|
||
const terminal = readline.createInterface({ | ||
input: process.stdin, | ||
}); | ||
|
||
|
||
const API_KEY = process.env.API_KEY; | ||
const CHANNEL_ID = process.env.CHANNEL_ID; | ||
const NAME = process.env.NAME; | ||
terminal.on('line', text => { | ||
const message = { name: NAME, text }; | ||
|
||
const payload = { | ||
"method": "publish", | ||
"params": { | ||
"channel": CHANNEL_ID, | ||
"data": message | ||
} | ||
}; | ||
|
||
axios.post('http://localhost:8000/api', payload, { | ||
headers: { Authorization: `apikey ${API_KEY}` } | ||
}).then(function (response) { | ||
console.log(`${JSON.stringify(message)} > ${response.status}: ${response.statusText}`); | ||
}).catch(function (error) { | ||
console.log(error); | ||
}); | ||
|
||
}); |
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 @@ | ||
import Centrifuge from 'centrifuge'; | ||
import WebSocket from 'ws'; | ||
|
||
const centrifuge = new Centrifuge('ws://localhost:8000/connection/websocket', { | ||
websocket: WebSocket | ||
}); | ||
|
||
const TOKEN = process.env.TOKEN; | ||
centrifuge.setToken(TOKEN); | ||
|
||
const CHANNEL_ID = process.env.CHANNEL_ID; | ||
centrifuge.subscribe(CHANNEL_ID, function (message) { | ||
console.log(message); | ||
}); | ||
|
||
|
||
|
||
console.log(centrifuge.connect()); |