Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to build a headless Node-based client from Meteor?

Tags:

node.js

meteor

I'm working on a system where a remote machine (hooked up to a projector and some other hardware) is controlled via a Meteor application. Currently, we are using a home-grown DDP client written in C++ to accomplish this, but this approach is not as flexible as I would like:

  • There is duplication between C++ and JavaScript.
  • Upgrades are hard because we can't deploy both the server and the client at the same time, so we always have to think about backwards compatibility and ordering.

So I'm toying with the idea of rewriting the Meteor part of the C++ app in JavaScript. What I would like, ideally, is to have a special client of our app (call it headless, akin to to server and client) which:

  • is built from the same source as the rest of the Meteor app, so we can reuse the same business logic as on the server and web client,
  • runs in Node.js on the client machine so it can access the OS, and
  • doesn't contain any of the browser code, but adds some other code specific to controlling the machine and communicating with the C++ app.

Even better would be if this client would not contain any of the actual code, but just a piece of bootstrap code. The bootstrapper would download the actual application code from the server and re-download it when the server is updated, in the same way as happens for the HTML client. That would make updates much easier, because we can assume that server and client are always running the same version.

Does such a thing exist? If not, how close can I get without unreasonable effort? Searches for "meteor headless client" and "meteor node client" are not helping me, and the only somewhat related question I could find isn't well answered.

like image 980
Thomas Avatar asked Nov 24 '16 08:11

Thomas


People also ask

Does Meteor use node?

Any database with a Node. js driver is supported by Meteor as we are a Node. js application on the server. MongoDB is usually the most used in Meteor community as it has more integrations with Meteor as well as a subscriptions model implemented on top of it.

Does Meteor use Express?

The basic platform allows you to add on whatever other framework you wish to the back end or front end. Everything from Angular, Express, React and Vue can be installed on top of Meteor.

What is Meteor JS used for?

Meteor, or MeteorJS, is a partly proprietary, mostly free and open-source isomorphic JavaScript web framework written using Node. js. Meteor allows for rapid prototyping and produces cross-platform (Android, iOS, Web) code.


1 Answers

You should be able to get this to work by using the meteor-desktop package to build your remote headless client.

https://www.npmjs.com/package/meteor-desktop#architecture

In Electron app, there are two processes running along in your app. The so-called main process and renderer process. Main process is just a JS code executed in node, and the renderer is a Chromium process. In this integration your Meteor app is being run in the renderer process and your desktop specific code runs in the main process. They are communicating through IPC events. Basically, the desktop side publishes its API as an IPC event listeners. In your Meteor code, calling it is as simple as Desktop.send('module', 'event');.

This will give you:

  • os access on this (desktop) client
  • hot code push (with caveats around the node modules)
  • provides Meteor.isDesktop to control which code runs on the browser vs the desktop client
like image 114
JeremyK Avatar answered Nov 09 '22 01:11

JeremyK