title: Is it bad practice to wrap express app within socketio connection?
body: <p>I'm making a webgame, and if I have a route that looks like:</p>
  
  <pre><code>app.post('/create_account', (req, res) =&gt; {
      var email = req.body.email
      var pass = req.body.pass
      res.json({response: "created"})
  })
  </code></pre>
  
  <p>Anyone can post data to mywebsite.com/create_account using postman, or curl or something, and my website will start creating account for them even though they are not even on my webpage.</p>
  
  <p>I found an interesting workaround, and I wanted to know if this is safe, or even a good idea. Basically I wrap my app routes within a socket.io connection:</p>
  
  <pre><code>io.on('connection', function(socket) {
      app.post('/create_account', (req, res) =&gt; {
          //code goes here
      })
  })
  </code></pre>
  
  <p>I tested it, and it seems that this way you can only post to /create_account if you are actually connected to the webpage.</p>
  
  <p>What (if any) are the disadvantages to doing this? If this is a bad idea, whats's a better way to prevent people from posting data if they aren't on my site.</p>