I am new to Node.js and I am still learning it as I try to attempt to solve a problem. However, I am stuck and need some input.
I have a website (for simplicity sake, let's call it MyMathPage.html) which does some mathematical calculations on the client side (using JavaScript) and displays the results.
So, the header of the MyMathPage.html looks somewhat like this:
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' type='text/css' href='../css/style.css'>
<script type='text/javascript' src='../js/jquery.js'></script>
<script type='text/javascript' src='../js/Maths.js'></script>
<script type='text/javascript' src='../js/GetAnswer.js'></script>
...
However, some of the mathematical functions take too long to solve (~15-20 seconds), so I am experimenting with Node.js to see if the processing within Maths.js can be done on the server side (on Node.js) to speed up the calculations a bit more, as the browser clients typically don't have a lot of memory or processing power.
My idea of the new architecture is this:
- GetAnswer.js calls var math = new Maths(calculationToMake, input) from the browser side
- On Node.js, I will have Maths.js which will accept the calculationToMake and input from the request, does all the calculation server side and returns a response (return MathsAnswer - of return type Maths)
- GetAnswer.js receives the response and displays the result.
My question is, if I take Maths.js file into node.js server side, how will my request for "var math = new Maths(var1, var2) )" from GetAnswer.js will look like? Also how will my response on the Node.js will look like?