Integrating ExpressJS and MeteorJS - javascript

I have an Epress JS rest api that posts values to the mongoDB. I'm wondering if it is possible to integrate Meteor JS to retrieve those values from the MongoDB.
Any thoughts would be appreciated.
Thanks

Meteor's data layer connects to MongoDB, use a normal publish on the server and subscribe from the client. https://www.meteor.com/tutorials/blaze/collections
It won't matter that your Express app updates the db independently - Meteor's reactivity will pick up the changes as they happen.

In meteor for creating REST-API the first choice would be a publish-subscribe call but if you need to make REST-API beyond that you can use 'Restivus' high-level API.
Here is the link

Related

Integrating React with Firebase using just react or node.js?

Im new to backend dev, and I have a full fledge working React app that GETs,DELETEs and PUTs data using a fake server. Now I need to use an actual backend and I was thinking of going with Firebase as it seems really convenient. However I saw some examples using Firebase directly in the React app, and some using Node.js to do the work.. Could someone please tell me whats the best way to go with this? If there's an easier way to create REST API using express/mongo, I am also open to those :)
You have to keep in mind that anything you do from the frontend will be visible to the user, so communicating with Firebase from React will be a bad idea at least for anything involving sensitive information (passwords, credit card info, etc.). Just because you can do something doesn't mean you should. Use a Node backend and use that to communicate with your DB and other services.
To address the last part of your question, it is possible that Firebase might be more than you need. A simple setup with Express and MongoDB might be easier. MLab has a pretty good free sandbox database-as-a-service that requires very minimal setup.
I think firebase can also be a good fit, you can use Firebase auth to manage authentication and Rules in the Realtime database or in Firestore to prevent not authenticated users to manipulate your data https://firebase.google.com/docs/database/security/ And to get the best out of Firebase I would recommend using the SDKs but you can also use the REST API https://firebase.google.com/docs/reference/rest/database/
Also if you want to have functionality on the backend you can do so With Firebase Admin SDK https://firebase.google.com/docs/reference/admin/
From my point of view that is one of the advantages of firebase, you can get con going really fast without having to worry about managing infrastructure.

How can I connect Ember.JS with a database?

I'd like to connect Ember.JS to a persistent datasource.
Ember.JS could manage the main parts of the application. Express.JS could assist to fetch data and save Ember.JS's app data in a database.
I've heard of stores, models and adapters... Honest, it confuses me a lot!
Could anyone explain the ways of connecting Ember to a database (maybe sqlite3)?
Thank you!
Ember.js is a web framework and is not really intended to be connected to a database directly. You should build an API (with express.js and node for example), and connect this API to your database. Then, Ember.js can talk to your API, through ember-data.
If you are building a mobile application, this should help: https://www.npmjs.com/package/ember-sqlite-adapter

Jade #{user.username} Partial Page Refresh

I'm using https://github.com/sahat/hackathon-starter/tree/es6 which leverages Jade in an ExpressJS & MongoDB NodeJS environment. My questions is how can I update #{event.location} && #{event.city} in Front-end if they change inside MongoDB in the back-end?
I do not want to refresh the entire website in order for #{event.location} and #{event.city} to be updated in the front-end.
Could someone please explain how to do this or if there is a better way of achieving this? Maybe with Socket.IO or some other way. I'm fairly new to Node, JS, Jade etc and can't even grasp a decent way of refreshing part of the page with JADE....
Thank you in advance for your help ! Kudos
Express/Jade can only render the page once from backend when the HTTP request comes.
If you have to update the data on frontend, you will have to use different strategy depending on how your data is updated.
If your data in the backend is updated via the same frontend or at known time you can use AJAX calls to server and fetch the values intermittently.
If data is updated via a different channel then socket.io would be the way to go. You can emit events from the backend on data change and receive the events on frontend app and update the data fields only using javascript bindings.
If you have too many manipulations of data to be done I would suggest using a frontend framework from the likes of Angular or Meteor.

Two-way communication between Meteor and Node

I am building a Node app that talks to an Xbee over serial and reads/controls several sensors/relays that are also Xbee equipped. I would like to use Meteor for the user interface and data storage with the Node app simply sending sensor updates and controlling the relays when triggered by the Meteor app. What would be the proper way to communicate between the Node and Meteor app? I know I can use a Node DDP client to insert sensor readings to the Meteor app. The part I am having problems with is sending commands from Meteor to the Node app to control the relays. I simply need to send a command that will execute certain code on the Node app to switch the relays. Maybe this is a simple question, but I'm not sure of the best way to accomplish this. Thanks in advance for any input.
You could just use Mongo as your point of integration. Each XBee device could just be a mongo document.
{
address: 'xbeeaddress',
relay1: 'on'
}

how to make an Angular.js app offline with server sync when available

I'm looking for an approach or a library that handles this. the idea is to store data in localstorage and sync to the backend when a connection is available, http://pouchdb.com/ looks like a cool solution but anyone has use it on production?
UPDATE:
Right now you can also use:
MeteorJS + Angular
Firebase
Parse
Horizon
Haven't used it yet, but familiar w/ the concepts behind BreezeJS from their other offerings in .NET. Check it out http://www.breezejs.com/ and here's Ward Bell presenting it to the Googlers
http://www.youtube.com/watch?v=P2ErSQj3SN8&feature=player_profilepage
you can also take a look at jaydata
http://jaydata.org/blog/synchronized-online-offline-data-applications-part-2-syncing-large-tables-and-tables-with-foreign-relations
breezejs is not a sync solution!
if server data changes what happen in local data
if some recordes deleted on server after last update local data must sync after a method called sync in other word some date must come back to client after calling savechange that tell client db to be sync with server

Categories

Resources