1.0.0 • Published 4 years ago

asmt1 v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

IT122-Adv-Javascript-NodeJS

Repository for IT 122: Advanced Javascript (Node.js) - Summer2020

WEEK1 - Node.js up and running

First step toward a working web server application. Should have following files and functionality:

--Files in the root directory: --package.json - with information about application --data.js - containing: --an array of at least 5 items (objects), where each item has at least 4 attributes --an exported getAll method that returns all array items --index.js - with code to launch a node.js web server on port 3000 and respond to requests. Should import data.js module. --Web server should send different responses for these urls: --http://localhost:3000 - shows some home-page information and total number of items in your array --http://localhost:3000/about - returns some information about self --Any other path returns a 404 status code and error message

WEEK2 - Express yourself

Simplify server application and add formatted pages, using Express and basic templating.

--Install these node modules: --express, express-handlebars & body-parser --Convert index.js code to use Express syntax, --Update default route to show formatted information for each item in data array: --create home.handlebars template --render this template for requests to default route --pass data array to the handlebars template --display the list of items in data array --each item is linked to detail page with a query parameter identifying the item --Create a new server route that: --can be accessed like so - http://localhost:3000/detail?item=[VALUE] --renders a detail.handlebars template to : --show an appropriate page title --show the value submitted on request url --show a link back to home page --Create a .gitignore file in project folder that excludes the node_modules folder from git commits.

WEEK3 - Quality Matters

Learned about test driven development and key techniques for ensuring code quality. Practicing those with a 2-part assignment.

First: --Install ESlint and initialize an ESlint configuration file using the 'eslint:recommended' rule set. --Then add these to the eslint 'rules' file: --"prefer-arrow-callback": "warn", --"no-var": "warn",

Second: --Create three new methods in data.js module: --getItem - should return full data about the requested item --addItem - should add a new item to the data array, if it doesn't already exist --deleteItem - should delete the requested item --Each method should return information on whether the operation succeeded or failed.

--Install the mocha and chai modules as 'dev dependencies' for the application. --Create a test script file in the /test folder, with Mocha+Chai test cases for the 'getItem', 'addItem' and 'deleteItem' methods. Create tests for both success & failure conditions. --All six test cases should pass when run via Mocha.

WEEK4 - DATABASE INTEGRATION

Storing data in MongoDb and accessing it with Node.js and Mongoose. For the online database, credentials provided via Canvas upon assigment submittal.

Update your Node.js application through the following steps:

install the mongoose npm package, --Create a data model that: --connects to your database --defines a data schema, --exports your data model for use by other scripts, --Populate the new database collection with items from your existing data array. --Update your server's 'home' and 'detail' routes to use the new database instead of your JavaScript data array. Your detail page should display details of the requested item. --Create a new server route to 'delete' an item from your database on request. Your route should accept a requestquery parameter identifying the item to delete, and should return a response indicating whether delete succeeded or failed.

1.0.0

4 years ago