PhoneGap AngularJS Strongloop MongoDB Firebase - angularjs

I'm trying to setup an alternative to Firebase with loopback API REST(with mongodb connector) in NodeJS, when I implement it with the $http ressource to my PhoneGap apps in AngularJS,
it is not update in realtime like Firebase.
My factory is like:
function syncUsers(){
return $http.get(userUrl).then(function(res){
return res.data;
});
in my controllers:
UserSrv.syncUsers().then(function(res)
{ $scope.data.users = res});
my question is : why my apps don't update the old data, and why I need to refresh the apps to have the new data ?
Thank you.

Ok even if I don't know how to implement it, I need to use pub/sub
Strong loop work on it.
https://github.com/strongloop/strong-pubsub/issues/7

Related

Using Lambda/API Gateway in ReactJS

I have a frontend that I designed in ReactJS on AWS Amplify with my Senior Project team and am looking to bring in data from API Gateway. I have a link I deployed that I tested in Lambda on the AWS console which works correctly. I am looking for some guidance on pulling in the data from that url to the frontend to use for a list. I can supply more information if you would like, please let me know what you need and any tips would be great! Thank you.
Assumption :
As mentioned in your question i assume that you already aware how to create API Gateway,deploy API and now you have API gateway url to access rest API.
Fetch data into react :
Example you have following cruds API
GET /students List all students
GET /students/1 Load a studentsby id
POST /students Create a students
PUT /students Update a students
DELETE /students/1 Delete a students by id
Fetching data:
import { API } from 'aws-amplify';
API.get('students', '/students', {}).then(result => {
this.todos = JSON.parse(result.body);
}).catch(err => {
console.log(err);
})
Security :
You need to secure rest API either use API key or Authorizer
https://github.com/vaquarkhan/aws-amplify-workshop-react
https://www.freecodecamp.org/news/going-serverless-with-react-and-aws-amplify-part-2-creating-and-using-serverless-services-d401ba346eeb/
https://gerard-sans.medium.com/create-a-rest-api-integrated-with-amazon-dynamodb-using-aws-amplify-and-vue-5be746e43c22

Push notification in Web pages

Can a web notification be implemented in web sites? I'm using a environment of jsp's with jquery, vue and angular.js for the front side. There's a way to implement web notifications with this environment?
You can use the Notification API to achieve this.
If you want to use Service Workers to push notifications from a backend, you can check the Push API
These API are still drafts and may only work with modern browsers. Make sure you are using these API's over https.
you can use web socket, which has integrated in Angular already.
use for example:
https://github.com/mqttjs
then in your js:
this.client = mqtt.connect(url, options);
if(topics.length>0)
this.client.subscribe(topics);
this.client.on("message", (topic:any, payload:any)=>{
console.log('CONNECTED', payload);
});
this.client.on("connect", function (connack: any) {
console.log('CONNECTED', connack);
});
And use some server side message broker eg: rabbitMQ or other message router
read this
https://www.rabbitmq.com/web-mqtt.html
Yes, Web notification primarily targeted for Web application, client side registration and server sider processing for pushing the notification, below site has both client and server side examples -
ServiceWorker

Which is the right method to handle oauth2.0 done in server using Ionic framework?

I am creating an Ionic app which has multiple 3rd party integration. I already have a java server which does the oauth2 authentication for the 3rd parties and redirect to the callback url in the server itself.
Now my task is to open back the app page after the server callback url is done.
I have tried the following method:
monitoring the url changes in app using ionic and redirect after the successful callback.
Which is the best way to handle this sitn.
Thanks.
Frankly, I haven't done anything like this. But to my mind, you can check ngcordova oauth implementation for ideas.
var browserRef = window.open(your_url);
browserRef.addEventListener("loadstart", function(event) {
//your code
});
browserRef.addEventListener('exit', function(event) {
deferred.reject("The sign in flow was canceled");
});
Check oauth.js source for more details.
Moreover, you can find the sample of using this implementation on this page.
http://mcgivery.com/using-custom-url-schemes-ionic-framework-app/
Above link may help you. If I am thinking correctly what you want?

angular-google-maps API key from backend

Generally, this question is about how to use some dynamic content from a backend inside a module.config function in AngularJS.
Specifically, this question is regarding the GoogleMapApi provider in angular-google-maps
In my Angular Application the Google Maps API key is stored in a Firebase backend. What I would like to do is to set the API key for the GoogleMapApiProvider
.config(function(uiGmapGoogleMapApiProvider) {
uiGmapGoogleMapApiProvider.configure({
key: 'your api key',
});
})
I know that I only have Providers and Constants available in the Angular module config function. So I struggle to think of a way to get the necessary API key from my Firebase backend using the $firebaseProvider
Any help or direction is most appreciated!
Thanks!

How can I mock the results of the GMail API?

We are using the GMail API and developing an application on top of it. Ideally I would like to have some golden emails to test the analytics engine against. This way I can develop the analytics engine without having to worry about fetching the emails and hence without a network connection. What is the best way to achieve this? I noticed that App Engine (which we use) now allows you to mock DataStore/memcache etc. and run nosetests, but I don't know how to do this across local appserver restarts.
The Mock class provided by googleapis/google-api-python-client looks like a good candidate for your use case.
from googleapiclient.discovery import build
from googleapiclient.http import HttpMock
mock = HttpMock('mock-email-list.json', {'status': '200'})
gmail = build('gmail', 'v1', http=mock)
response = gmail.users().messages().list(userId='me').execute()
print(response)
Where mock-email-list.json content is of the form
{
"messages":[
{
"id":"abcd",
"threadId":"abcd"
},
{
"id":"efgh",
"threadId":"abcd"
},
],
"resultSizeEstimate":2
}
As a side note, after your test has run, you can also check what url the mock has been used for (by the gmail client):
assert mock.uri == 'https://gmail.googleapis.com/gmail/v1/users/me/messages?alt=json'
The Gmail API nor the client libraries provide special functionality for mocking email fetching. You'll need to build out the mocks on your own.

Resources