Question: The Node.js provides service at http://localhost:8088/ (for the get) and http://localhost:8088/api/user (for the post). The main file should be server.js. To run the app, use

The Node.js provides service at http://localhost:8088/ (for the get) and http://localhost:8088/api/user (for the post). The main file should be server.js. To run the app, use the command node server.js

Get Request Process

If the user access the http://localhost:8088/ using a get request, it return the following page to the user. All the view file and style files (should be in a static resource folder) are retrieved from the backend.

1)Put User Login in the center, set its font size to 20pt and color to blue

2)Create a form and set its width to 400px, height to 250px and put it in the center of browser (hint: set both margin-left and margin-right style to auto). Set its margin-top to 20px and padding (all sides) to 10px. Set its border to 5px solid orange.

3)Create label for each input box (maximum length is 12). The first text input is for user name and the other two are for password (it shows star when you type in something set its TextMode property to Password). All align to left and put label and its input box in the same line with margin-top to 20px.

Create a submit button

When user clicks on the submit button, it posts the user data to the backend http://localhost:8088/api/user.

Post Request Process

In the backend Node.js application, the code validates all user inputs. If there is any error, it sends the page back as the following:

All input boxes must have text whose length is >=4 and <=8. If any of the input text is too short or too long, set the message label text to The length of user name and password must be between 4 and 8. The message should be in red color.

The password and verified password have same text. Otherwise, set message label text to The passwords are different. The message should be in red color.

If the inputs are valid, the backend generates a user id, starting from 1001, increase by 1 for each request and send back to the front end. The front end displays the result with a message: The user is created with an id of 1001. Creating another user will create a user with id of 1002.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!