Skip to content
Permalink
1e1f20511a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Programming Refresher NodeJS

If you are completing this worksheet it is assumed that you are already familiar with both NodeJS and the Express package that is used to build dynamic websites. This worksheet will serve as a refresher whilst learning how to use a technique called Test-Driven Development which you will need to apply on a regular basis during the remainder of this module.

If you are not familiar with NodeJS and Express ask your lab tutor for additional resources.

Navigate to the exercises/01_tdd_nodejs directory and open the package.json file. Notice that there are certain modules listed as dependencies and others labelled as devDependencies. Use the npm install command to install all of these.

If you examine the folder structure you will see that there are several directories:

  1. The modules/ directory contains the three modules that will contain the business logic plus a __mocks__ directory that we will be exploring at a later stage.
  2. The __tests__/ directory contains test scripts that matche each of the modules
  3. The html directory contains the page templates used by the express renderer
  4. The public directory contains files that can be directly accessed by the web server
├── __tests__
│   ├── books.test.js
│   ├── google.test.js
│   └── utility.test.js
├── html
│   └── index.html
├── index.js
├── modules
│   ├── __mocks__
│   └── google.js
│   ├── books.js
│   ├── google.js
│   └── utility.js
├── node_modules
├── package-lock.json
├── package.json
└── public
    └── style.css

Start the web server using node index.js and access the URL (this will be localhost:8080 if you are running it on your workstation).

│   │   └── __mockData__
│   │       ├── 9781785885581.json
│   │       ├── 9781785885587.json
│   │       ├── extractedData.json
│   │       ├── java.json
│   │       ├── req.json
│   │       └── validTable.txt

TDD

7 Preparation

You will need to ensure your skills are up to date before we begin preparation in week 3.

7.2 API Team

  1. Subscribe to an MQTT data feed on Adafruit using NodeJS and print data to terminal. There is a good online tutorial to get you started.
  2. Build an MQTT server. Heroku offer a free hosting option

7.3 Front End

  1. Get familiar with the mapping APIs! (Google Maps / Apple Maps)