Last active
January 16, 2023 14:45
-
-
Save Alex-Werner/3cabab2ba09ea749a4c38b70326f9acf to your computer and use it in GitHub Desktop.
Moleculer JS NATS and Scaleway Messenging JS Code
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
const { ServiceBroker } = require('moleculer'); | |
const { credsAuthenticator } = require('nats'); | |
// Format of process.env.CREDENTIALS | |
// -----BEGIN NATS USER JWT----- | |
// ... | |
// ------END NATS USER JWT------ | |
// -----BEGIN USER NKEY SEED----- | |
// SUAF... | |
// ------END USER NKEY SEED------ | |
const broker = new ServiceBroker({ | |
namespace: 'myspace', | |
nodeID: process.argv[2] || `myprocess-${address}-${process.pid}`, | |
transporter: { | |
type: 'NATS', | |
options: { | |
url: process.env.NATS_URL, | |
authenticator: credsAuthenticator(new TextEncoder().encode(process.env.CREDENTIALS)), | |
}, | |
}, | |
logger: console, | |
logLevel: process.env.LOGLEVEL, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment