lab 2- 442

ITMD 442/542 Lab 2 Objective In this lab you practice the concepts of the CRUD operations (create, read, update, delete) in a Node JS Express application. The objective of this assignment is to make a Node JS Express application that acts as a contact database and allows the user to create, edit, view, or delete individual contacts. The home page will list all the contacts and from there the user can view, edit, delete, or add a contact. You will not use a database for this app to store persistent data, instead you will need to persist the data using a file on the file system as show in class demos. Requirements • • • • • • • • • • • • Build a contact database application in Node JS and Express No authentication on this application this time since we haven’t discussed that yet Use express-generator to create your project for you, make use you update all dependencies with npm-check-updates as show in class before you start. Initialize this project directory as a new git and github repository or use the existing repository you created in Lab 1. Do not commit your node_modules directory to your repository so exclude it with a .gitignore file. Commit your code to the repo often as you implement features. I do not want to see the project go from nothing to finished in one commit. That is a warning sign that you did not do all the work yourself. Use whatever template/view engine you like but I would recommend pug. Use standard HTML templates and forms vs any front-end JavaScript. You may use any CSS frameworks or libraries you like if you want. A contact should consist of the following data o Contact ID (Unique identifier to use as a key, not user entered/changeable, generated in code) o First Name (text – Required) o Last Name (text – Required) o Email Address (text – Not Required) o Notes (textarea – Not Required) o Date/time created or last edited (not user entered, value generated in code, only displayed on single contact page) Individual Contact can be modeled as an object literal or class. All contacts data should be modeled as an array or map of objects All contacts data needs to be saved to a data file in your project directory. Use a JSON file and data structure to persist the data and use the NodeJS file system API to read and write the file. Every page load needs to read that data back into a workable data structure. Every time the data is modified you need to save it back to the file. • • • • • • • The index route ( / ) of your application should just be an introduction page to the application and a link/button to “View Contacts Database”. On this introduction page include a title, some intro info about the application/lab, and your contact info. Make your urls follow a RESTful pattern as much as possible. The main list view of all contacts should be at /contacts. On the main all contacts page ( /contacts ) you may display the list of contacts as a table or any other HTML structure you like to use. The only data I want to see on the all contacts list page is First Name, Last Name, Email Address and a way to get to the single contact detail view page. The single contact view page ( /contacts/id ) should show the details of the single contact selected. Including First Name, Last Name, Email Address, Notes, Date Created/Modified, and ways to edit or delete the contact. Make sure you label each data field so the user knows what it is. The create and edit contact form pages will look similar. Make sure you label all fields, so it is clear to the user what is being entered. The user does not enter/edit a contact id or date created/modified. Those are handled in your code programmatically. Make sure you show validation error messages for required fields. Do not use GET methods for any operations that could modify data. Those must go through POST methods. Make sure you validate required fields in your code, don’t just rely on a required attribute on the html input field. Remove all leading or trailing whitespace in any form field. Sanitize user input, do not allow the user to inject HTML/CSS/JavaScript into any form field. PUG will escape any output text for you if you use the templates syntax correctly so this shouldn’t be too difficult. Graduate Additional Requirements If you are involved in any section of 542 you need to complete the additional requirements listed here. • • • • Use HTML/CSS to present the application nicely (bootstrap or another CSS framework is ok). I expect it to not just look like plain basic html in the browser. You must abstract out your database logic to a separate module, like repository pattern demonstrated in class, instead of just putting it in your route files. Add a README file as described below to your project Applications will be held and graded to a higher standard if you are in a 542 section. README File Produce a README file in your project that describes some components of this assignment. The readme doesn’t have to be long but should include a few things. The readme should be either a plain text (README.txt) file or a markdown (README.md) file. • Your Name • Your Email • • • The Class and Assignment Numbers Git repository URL The following sections o Project Description – Brief introduction describing the project in your own words. o Development Environment – Description of your development environment. Include things like computer OS, Node JS version number, editors used, and any other details you think you should include about your environment o Installation/Running Instructions – Include any instructions on how to get the project up and running. Assume someone that doesn’t know how to run an Express or Node JS application. Give the steps from a cloned repository to install dependencies and start the application. o Insights and Results – Include here things you learned, challenges or problems you faced, and any details about the results you received. If you couldn’t get something working this would be the place to describe what you tried and what wouldn’t work. Feel free to embed screenshots for working and non-working features. o References (if needed)– Any resources you need to cite of that you might have used for assistance. Not an excuse to copy and paste but if you need to cite a source, do it here. Due Date / Late Policy This assignment is due Sunday February 18, 2024 11:59 PM Chicago Time. Late assignments will receive a 10% per day deduction starting at 1 minute late. We will discuss this in the following class so no assignments will be accepted as of class (6:25pm) that night. See syllabus for full late policy. No Extensions. Submission Guidelines You must upload your submission, to the blackboard assignment by the due date. The submission must be in the following format and structure. If you do not submit your assignment exactly as specified, you will receive an immediate 10% deduction. Submission Format Specification: Commit all files used to your GitHub Repository and submit to the Blackboard assignment the URL to your GitHub repository where this project is hosted. Also include a note so that I know what npm command I need to run to start your application. I will expect to be able to clone down your repository, run npm i to install dependencies, and run your application without problems so you should test this yourself before submitting.

lab 2- 442

We offer the best custom writing paper services. We have answered this question before and we can also do it for you.

GET STARTED TODAY AND GET A 20% DISCOUNT coupon code DISC20

Leave a Comment