Nodejs encrypted comunnication with frontend (javascript) - node.js

I am sending a JSON with some important data to the frontend using Nodejs.
If i enter in the explorer the url of the JSON i am requesting the json data is displayed.
Also, if i firebug the website i am able to view the POST or GET requests with that important data.
I need a way of communicating with from backend to frontend but being encrypted so that nobody can never see that important data.
I am thinking of using google fusion tables (excel in the cloud) to achieve this, but i am sure there must be a simpler solution.
Regards,

Related

External API Calls server or client side?

I'm currently working on an analytics webapp with a react frontend and node (express) backend.
Describing the functionality in a nutshell:
A user will be able to login on the website, search for a YouTube username and then the YouTube API is called, the data will be stored in a mysql db via my express API and also the data will be used to calucalte some statistics which afterwards are displayed in a dashboard.
Now I was wondering if I should:
Call the YouTube API from the frontend, i.e. inside my react code, do the calculations display them and and then store it in the DB via my express API.
Or, from the react app call an endpoint in my express API that will then call the YouTube API, store the data in the DB and then pass on the data to my react app.
Are there any best practices or up-/downsides to either approach?
When answering questions like these, it's important to remember that the client-side is different for each and every user that visits your website, their internet speed, their GPU & CPU power, etc., but the server is most commonly held in a stable container and much more powerful than a client.
The proper way would be the following:
1. Obtain a search query from a client
Meaning you should get the user's search query from an input, or any other form of control (text area, checkbox, etc.), this way client is doing the least business logic, as it should. The client should always focus more on UI / UX rather than business logic.
2. Send query to the server
Let the server use the query you've just obtained from client, call the youtube api from the server (either explicitly using Axios, or find a node.js youtube library), and do all the necessary calculation on the backend
3. Send processed data to the client
Let client receive the data in the form which is ready for use (iterations, mappings, etc.) - again separating concerns, server - business logic, client - UI / UX
Now to be fair, the example you have will most commonly be done all on the client-side, since it is not as computationally heavy as other enterprise examples, but this is a good rule to follow for big projects, and no one would really complain if you did it this way, since it would be the proper way.

How do i put the request result inside an html in express?

im trying to make a website using express, and in this website i request some data from an external API.
So, i have an html where i "send" the request. How do i take that parameters for the request into the server, and then the response to the html or at least the js linked to that html?
To this point, i already tested how to add an html with a js linked to it, and it worked, so now i have to make the rest of the web concept, that is request data from the API.
Sorry if i dont have the code, but im still making it and i have this big issue that i cant resolve.
Thanks for your time and advice anyways
You have two choices.
Either you make an ajax request to the api from the front-end or in the back-end and render the result.
You can also make a request from the front-end, send the result to the back-end and have express send a different response.
No code attached as your question is very generic.

Sending data without redirect?

I want to send data to the client without having it redirect and show the data in the browser. The server is written in node.js using express.js.
It is for a login function.
I need to have it work like this since the idea of the system is to use the front-end purely as a GUI for interacting with the API.
res.send("Login failed").redirect(homepage);
I've seen framework-engine which I suppose I could use, but I would like to avoid as much additional "software" as possible. Essentially my question is: How do I send data back to the client so that it can be used in an already shown HTML page.

Send image in formData without file input

I've been scouring the internet on this one, but I can't seem to find a situation exactly like what I'm trying to do....
I've built a React app (using CRA) which is used to import products from an existing eBay-like site (Reverb.com), make some small modifications, and then post them to a server which, in turn, manages the products on multiple eCommerce platforms. Pulling the data in from the Reverb.com API is easy enough; the problem comes when I submit the data to my local server's API. I need to post the product images from Reverb.com via formData without the user having to manually choose the files via a form input, but I don't have access to fs.createReadStream(). How can I get from an image URL to a file posted via formData?

Making Firebase and Angular2 project

I'm new at Firebase, I'm starting making a project which has to include Firebase and angular2, but I am such confused about how to implement them. I don't know if a there's the need to have a Back-end implementation (like Java or NodeJs) to handle some security issues (like form validation, authentication, routing etc), or it's enough just implementing Angular2 to handle all these issues. I would be so Thankful about any helpful advice how I could implement these both technologies to build my project successfully. Thanks
first firebase is something like your backend firebase can safe get and send request as your backend apps...
and angular js will do the rest like you just said andd all the backend stuff you can handle by firebase :)
This is my simple explanation on how this 2 works together
Always keep in mind that Angular works only in front-end. Its domain is the look and feel, application events, sending data to server and anything else that has something to do with displaying data is coded in this area.
Backend services in the other hand interacts with your database, creating business logic, handling authentications, saving / sending of data and other stuff that interacts with the database is coded from here.
Now how these two interact is done by the frontend service to send HTTP requests to the Server which is the backend service. This is done by using Angulars $http service or the so called jQuery AJAX or the infamous XMLHttpRequest JavaScript native. New technologies today utilizes Web Sockets which is being used by Firebase and some other frameworks, Web Sockets offers a faster way sending / fetching data from server.
The server then interprets the data being sent and send appropriate response. For example getting user list, saving profile, getting reports, logging in, etc.. It would work in this workflow.
1) Angular sends http request to server to get list of users.
2) Backend service installed in the server then interprets the data being sent.
3) Backend service then gets list of users from the database.
4) Backend then sends the data back to the frontend service.
5) Frontend then recieves server response and displays the data to the view.
Also these two is coded separately. To have more detailed explations research about how frontend and backend services interact you can find so much resouces in Google.

Resources