title: How do i filter API responses in nodejs/express
body: <p>I'm trying to make a chat app using the following Components (i just write everything here, because I don't know which information are important, sorry):
  Angular, Nodejs, Expressjs, MongoDB, Mongoose</p>
  
  <p>I have multiple DB entries for <code>localhost:3000/message</code> in the schema of <code>[{content: "this is a message(text)", sender: "1337(number)", receiver:"42(number)"}]</code></p>
  
  <p>Now i want to display in my angular page only the entries where the current user (via his by mongo generated ID) is either a sender of receiver (so basically the messages he is alowed to see).</p>
  
  <p>Of course i canrequest all messages and then filter them in my frontend, but this seems to me like bad practice and a massive security issue if i want to put the page online and everyone can request all the messages if they find the api. </p>
  
  <p>A different approach I thought of is making a route to <code>/message/:userID</code> where his messages are stored. This may conflict with <code>/message/:messageID</code> where you can put/delete a single massage. This is not very likely but very problematic if it occurs</p>
  
  <p>What shall I choose and how to do it or is there a mighty tool/practice that i didn't find yet?</p>
  
  <p>Thank you in advance</p>