-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function to init wallet, pool, vcx memory independently. Bump ver…
…sion Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
- Loading branch information
1 parent
0a5b6d3
commit bac255a
Showing
25 changed files
with
754 additions
and
152 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
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,55 @@ | ||
const express = require('express') | ||
const bodyParser = require('body-parser') | ||
|
||
const PORT = 7209 | ||
|
||
const app = express() | ||
app.use(bodyParser.json()) | ||
|
||
const FgRed = '\x1b[31m' | ||
const FgGreen = '\x1b[32m' | ||
const FgYellow = '\x1b[33m' | ||
const FgBlue = '\x1b[34m' | ||
const FgMagenta = '\x1b[35m' | ||
const FgCyan = '\x1b[36m' | ||
const FgWhite = '\x1b[37m' | ||
|
||
const colors = [FgRed, FgGreen, FgYellow, FgBlue, FgMagenta, FgCyan, FgWhite] | ||
let colorIdx = 0 | ||
|
||
const agentColors = {} | ||
|
||
function getAgentColor (agentId) { | ||
if (!agentColors[agentId]) { | ||
agentColors[agentId] = colors[colorIdx] | ||
colorIdx = (colorIdx + 1) % colors.length | ||
} | ||
return agentColors[agentId] | ||
} | ||
|
||
async function run () { | ||
const notifications = {} | ||
|
||
app.post('/notifications/:agentId', async function (req, res) { | ||
const { agentId } = req.params | ||
console.log(getAgentColor(agentId), `${new Date()}] ${agentId}: ${JSON.stringify(req.body, null, 2)}`) | ||
if (!notifications[agentId]) { | ||
notifications[agentId] = [] | ||
} | ||
notifications[agentId].push(req.body) | ||
return res.status(200).send() | ||
}) | ||
|
||
app.get('/notifications', async function (req, res) { | ||
return res.status(200).send(JSON.stringify(notifications)) | ||
}) | ||
|
||
app.use(function (req, res, next) { | ||
console.error(`Request ${req.method} '${req.originalUrl}' was not matched with any handler.\nRequest header:${JSON.stringify(req.headers, null, 2)}\nRequest body: ${JSON.stringify(req.body, null, 2)}`) | ||
res.status(404).send({ message: `Your request: '${req.originalUrl}' didn't reach any handler.` }) | ||
}) | ||
|
||
app.listen(PORT, () => console.log(`Server listening on port ${PORT}!`)) | ||
} | ||
|
||
run() |
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
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
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
Oops, something went wrong.