top of page

Node.js server application I Sample assignment

Question:

Write code in javascript for developing the creation of node. js server application with a server page named server. js and a client page named index. html.

The client page (index.html) will include with the following field.

  1. Customerid

  2. Firstname

  3. Lastname

  4. Address

  5. City

  6. Province

  7. Postalcode

Requirements:

  1. Allow users to maintain customer data using a web page where maintenance means the ability to add new customers, update existing customer data, delete customers and find a specific customer by customer number (CRUD).

  2. You’ll need to use AJAX to issue post requests (with responses) between the html page and the Node.js server.

  3. It is recommended that you use jQuery AJAX to manage the client-side post requests and response call backs.

UI Requirements:

  1. The New button must clear all the text boxes.

  2. The Add button verifies that all fields have some content and if so, will issue a POST request to the server to attempt to add a new customer record. The POST request will consist of a JSON string containing all the field data. If subsequently, the customer # is found to be not unique, the server will not add the new record and will return a suitable error message. If the customer # is unique, a new file will be created using the customer # + “.txt” as the file name and the JSON string received from the browser as the content – for example” “123.txt”.

  3. The Update button verifies that all fields have some content and if so, will issue a POST request to the server to attempt to update the file for the current customer #. If the file for the customer # does not exist, return an error message otherwise overwrite the file with the new JSON data.

  4. The Delete button will first use the JavaScript “confirm” function to have the user verify the decision to delete the customer. If the deletion is confirmed, take the current customer # and issue a POST request to the server to delete the relevant file. When the response comes back to the browser, clear all fields

  5. The Find button will take the current customer # and issue a POST request to the server to read the JSON string from the file for the current customer and return that string as the response to the browser. The client-side JavaScript will then take the returned JSON, convert it to a JavaScript object and populate all the text boxes.

  6. All files discussed above must be stored in a folder on the server called “data”.


Comments


bottom of page