HTTP POST requests for http://localhost:3000/login. The middleware should parse the body of the HTTP POST request and
Question:
HTTP POST requests for http://localhost:3000/login. The middleware should parse the body of the HTTP POST request and extract the username and password carried in request body (Hint: use bodyParser.json()). Then it checks whether the username and password match any record in the userList collection in the database. If no, send ?Login failure? in the body of the response message. If yes, create a session variable ?userId? and store this user?s _id in the variable, and update ?status? of the user in userList collection to ?Online?; send name and icon of the current user, name and _id of friends of the current user and the number of messages that the user has not loaded in the conversation with each friend as a JSON string in the body of the response message if database operations are successful and the error message if failure. Again, you should design the format of the JSON string.
Attached here is the code I have written and need help to finish this part:
Computer Networking A Top-Down Approach
ISBN: 978-0136079675
5th edition
Authors: James F. Kurose, Keith W. Ross