Saturday 25 May 2019

How to perform calculations in Node and making some data available easily around the app?

I am developing an app to learn MERN stack, it basically allows a user to login via facebook oauth using passport.js and then show basic stats that are available through the FB Graph API.I have successfully implemented the auth flow in Express, storing the user in my MongoDB if a new user logs in. Thing is after this I do not understand how to further structure my app, I am trying to use the MVC pattern or MVC without the V I guess since React is on the front-end.I need to perform some calculations to aggregate data that is coming in from the Graph API regarding different posts of the user. I have read that you do not write synchronous code in Node for performance reasons, so should I be using Task queues (e.g. Kue) to handle these calculations so that my application can be easily scaled or is there some other way?Secondly, FB Graph API basically requires the access token to be included in every request that is made. I have got the basic user identification metadata in my passport.use function but I do not understand how to pass this access token around my app. I need to write different controllers that can access different parts of the Graph API so is there a good way in which I can make this access token available wherever I need to make a request to FB?

Submitted May 25, 2019 at 10:16PM by captainforg

No comments:

Post a Comment