Customer APP - naveenamadepally13/customerApp GitHub Wiki

Lab 6 Assignment

Team: 3-2

Team Members:

Name: Neha Navgale Class ID: 19

Name: Naveena Madepally Class ID: 17

Assignment Objective:

The purpose of this assignment is to develop a Customer APP to perform CRUD operations on Customers Data stored in JSON.

Languages Used:

Javascript

Tool Used:

WebStorm, GitHub

Framework Used:

Node, Express, Yargs, Lodash

Introduction:

The APP will allow to create, read, update and delete customer's data. All the operations will be performed on the data stored in JSON.

Design/Implementation:

Develop Customer APP using Express framework:

In order to develop API we have followed below steps:

  1. Verifies Node JS installation by checking version using command: npm -v
  2. Created new customerapp directory by using command: npm init. This will create package.json and package-lock.json
  3. Installed Express : npm install express --save. This dependency will be added in package
  4. Installed package ladash: npm i --save lodash
  5. Installed package yargs: npm i yargs --save
  6. Created two JS files index.js and customers.js file. Index.js is the entry point for APP.
  7. Created customers.json file to store data of customers

UI Design:

No UI.

JavaScript Code:

Index.js: This is the entry file for performing CRUD operations. We have defined Customer's ID, Name and email as three input parameters and assigned alias for this parameters for the user to pass values. Yargs is used for reading and parsing arguments passed in command line.

User will have five commands to perform different operations: add, read, update, delete and list commands. Following are the commands to perform operations:

ADD: node index.js add -i <customer_id> -n <customer_name> -e <customer_email>

Read: node index.js read -e <customer_email>

Update: node index.js update -e <customer_email> -n <customer_name>

Delete: node index.js delete -e <customer_email>

List: node index.js list

While reading the command line we are checking the command name and calling the respective methods in customers.js file to perform operation.

Below is the screenshot of the file. index

index

Customer.js: This file contains all the methods for performing CRUD operations. This is the file interacting with JSON to add, update, read and delete data. CRUD methods created in this file are exported to make methods accessible in index.js file.

Below is the screenshot of the file. customer

customer

customer

Input:

Add Customer

add

Read Customer

read

Update Customer

update

Delete Customer

delete

List Customers

list

Output:

Add Customer

add

Read Customer

read

Update Customer

update

Delete Customer

delete

List Customers

list

Validation:

While adding new customer to JSON, we are first checking if the customer with same details is already exist in the JSON. If not, we will add the customer to JSON.

Contribution

Naveena Madepally -17

1.Setup the project repository.

2.Implemented Update, delete and log methods

3.Documentation.

Neha Navgale - 19

1.Setup the APP and basic installations.

2.Implemented add, read and list methods.

3.Documentation

Conclusion:

While working on this assignment we learned about nodeJs, express, middleware, yargs and lodash