title: How to build a typical REST type system with Node.js
body: <p>I am really confused on how to build a typical REST type web app with Node.js (even though I am using Sockets). </p>
  
  <p>In a typical WAMP stack you have a public javascript file and server-side PHP files. The user might be able to execute a JS function like</p>
  
  <p>function updateDetails(){</p>
  
  <pre><code> $.post('details.php', formData, function(data){
        console.log(data);
     },'json');
  }
  </code></pre>
  
  <p>And the server-side PHP file is something like</p>
  
  <pre><code>var stmt = "UPDATE table SET user = :user";
  var params = (':user', $user);
  stmt-&gt;execute();
  </code></pre>
  
  <p>Now I do know about node-mysql, but I don't see how it is implemented in the same way. How can I maintain a list of statements on the server side and allow the user to simply execute these statements on the client side.</p>
  
  <p>I have node_modules/mysql installed.</p>
  
  <p>In my server (app.js) </p>
  
  <pre><code>var mysql = require('mysql'); 
  </code></pre>
  
  <p>But unless I add all my statements there, I don't seem to be able to access them from a public JS file. </p>