Skip to content

isaac-nls/moleculer-browser

 
 

Repository files navigation

moleculer-browser

Build Status JavaScript Style Guide standard-readme compliant stability-experimental

Moleculer for the browser.

moleculer-browser is a wrapper on top of Moleculer.

Most of the 90% of the Moleculer's codebase is platform agnostic.

Using rollup we replaced the specific code for Node.js with shims to simulate the original behaviour.

Install

$ npm install @geut/moleculer-browser

Usage

const { ServiceBroker } = require('@geut/moleculer-browser')

const broker = new ServiceBroker({
  transporter: { type: 'fake' },
  serializer: 'Json',
  logger: console
})

broker.createService({
  name: 'math',
  actions: {
    add (ctx) {
      return Number(ctx.params.a) + Number(ctx.params.b)
    }
  }
})

broker.start()
// Call service
  .then(() => broker.call('math.add', { a: 5, b: 3 }))
  .then(res => console.log('5 + 3 =', res))
  .catch(err => console.error(`Error occured! ${err.message}`))

Playground

Glitch

view source remix this

Codesandbox

Edit moleculer-browser

Why

When we talk about services we think at some point in a process running in some environment. Well, the browser is a process too.

What if the browser could provide a service itself through a network on top of WebSockets or WebRTC?

That's what we want to show here.

Issues

🐛 If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

👥 Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project

About

Moleculer for the browser.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.1%
  • HTML 1.9%