Dynamically changing mobile server from meteor phonegap application - javascript

I have one meteor 1.0 phonegap application and several meteor servers.
According to the documentation, one can specify the server while building a phongeap cordova application https://github.com/meteor/meteor/wiki/Meteor-Cordova-Phonegap-integration
What I want to do is to set some default server and allow the users of the phonegap application to change the server from the application. How can I do it?

#MeteorAtSO I think the loadbalancer will do for you

The solution for this problem was the following:
I created a package which must be loaded before any other package and which tries to read server address from localStorage. If an address is found there the package sets __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = "theValueFromLocalStorage"
Which results in that the other packages start to refer to the new server the same way as if it was set initially when building the application
The package can be found here https://github.com/partus/meteor-server-picker

Related

Store redux data that can be accessible with swift and java

I want to rewrite my React Native application with Java for Android and Swift for iOS. The thing is, I don't want to lose application data so that the user has to set up the application again.
Imagine we're on version 2.0.0 (Written in RN) and version 3.0.0 is written in Java and Swift. I want to store my redux store somewhere so that I can retrieve that on the native side and after the user updates the app.
I found this library to store app data into a .plist file that can be accessed with Swift later on. I don't know if that's the right way for iOS and also I have no clue of what should I do for Android side.
Note that I can't get the config file from the network and I'm using redux-persist to persist the data for my app.
Any help would be appreciated.
I guess you can integrate a minimum react native module within your new native apps, and make it provide a data migration path for your existing customers. Not sure how you will solve this with a decent UX though.
https://reactnative.dev/docs/integration-with-existing-apps

How to get the latest cms posts data in a gatsby built project?

I've build a static website with gatsby and it workes fine . The problem is When I change the posts title and body in contentful cms and refresh the website it doesn't fetch the latest updated version of posts.
How can I always get the latest posts from a cms like contentful ? Do I have to rebuild the whole project and then redeploy the built files to hosting service everytime there is an update in cms posts ?
Yes, Gatsby is a static site generator so you have to rebuild after changes in your CMS. Where are you hosting? Netlify is a hosting platform that does this for you automatically.
As it has been said, Gatsby is a static site generator and it needs to re-fetch the data in the build time, so you'll need to redeploy the site. There's an automated way, however, to achieve this, called webhook.
A webhook is a way for an application to notify another application when a new event has occurred in real-time. In your case, once your data has been updated, deleted, or created, the webhook will trigger into the server the new deploy.
Depending on your host, the webhook is automatically set (like Netlify, because every change is a branch that is merged in a pull-request once the deploy occurs) or needs to be built from scratch.

Using MongoDB locally (electron)?

I need to store some data as part of my electron application. I know how to set up a REST API, and serve my application like so. However, is it also possible to use (e.g.) MongoDB locally, and implement something similar to a REST API locally? I would like to not assume an internet connection for this project.
If you need to implement a mongoDB like database locally for the application without internet, you can use lowdb
Yes it is possible, you have nodejs in electron so you can use mongoose:
https://github.com/Automattic/mongoose
But in this case every person who use your application have to install mongodb in his machine.

deploying an angular app on aws cloudfront

I have a laravel php app which is basically an api that the user will access through an angular single page app. Currently the angular app is contained with the public folder but I want to break it off on its own so that I can deploy it via amazon cloudfront.
I found this article for hosting static websites on CloudFront which explains the basics but I cannot find anything that discusses the hitting of an api with your cdn served site.
I would like to still be able to have 3 different environments, dev/staging and production which each currently have their own elastic beanstalk managed instances and seperate databases. I would like their addresses to be dev.blah.com / staging.blah.com and blah.com respectively and have each version of the angular app hit the correct backend etc.
I would like to be able to deploy the angular app in a similar way to how I deploy to elastic beanstalk, ie git push
Can I set it up so I dont need to modify the api endpoints in the angular app for each environment. ie the dev version hits dev.blah.com/get/user/1 and with the same source the staging hits staging.blah.com/get/user/1? Will this happen automatically or do I need to take specific actions to allow for this?
Are all these things possible? I dont expect a step by step guide but just looking for an outline of the process and a push towards where I can find the resources to learn how to do this myself as my searches have not resulted in much
On CloudFront, in the "behaviors" tab of your distribution, you can assign a path to every origin. For example, you can specify that /* requests are redirected to a S3 bucket with your static resources but /api/* is redirected to your api backend.
As for the dev/staging/prod environments, those would probably be 3 different distributions too. They can point to the same or to different origins.
See "Whole Site Delivery with CloudFront"

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'
}

Categories

Resources