06. Introduction to Node - Copy

MIS3406: Cloud Architecture Introduction to Node.js

Page 1

  • Topic Introduced: Cloud Architecture using Node.js

Page 2: Opening Questions

  • Define AWS Lambda function.

  • Discuss the role of AWS Lambda in serverless architecture.

    • How it benefits application development and digital services.

Page 3: Disadvantages of a Monolithic Application

  • Interdependencies: Difficulties in coordinating teams and components.

  • Decreased Productivity: Hinders developer efficiency.

  • Technology Limitations: Restricts hiring and requires specialized training in a single tech stack.

  • Major Changes: Any alterations to tech stack necessitate extensive projects.

  • Shared Release Pipeline: Complicated testing due to the need for comprehensive regression tests.

Page 4: Benefits of Serverless Architecture

  • Accelerated Feature Release: Quickly implement new features.

  • Reduced Maintenance: Less effort needed for ongoing support of features.

  • Independent Scaling: Scale services individually based on demand.

  • Tech Stack Flexibility: Choose contextual tech stacks and data stores for each service.

  • Frequent Deployment: Change and deploy services independently at will.

  • Focus on Innovation: Allows teams to concentrate on specific services without affecting others.

Page 5: AWS Lambda Features

  • Custom Code: Users can bring their own code for execution.

  • Loose Coupling: Development not tightly integrated with AWS services.

  • Integration: Works seamlessly with other AWS services.

  • Resource Management: Flexible resource allocation and concurrency settings.

  • Permission Control: IAM for fine-grained permission management.

  • Managed Service: Reduces costs by only consuming resources when invoked.

  • Fault Tolerance: Built-in features ensure availability and resilience.

Page 6: Course Agenda

  • Refresh on programming basics.

  • Learn to create server-side applications (APIs).

  • Deploy simple server-side programs in the cloud.

  • Preparation for future coursework in MIS3502.

Page 7: Learning Objectives

  • Understand similarities and differences between Node.js and JavaScript.

  • Write a basic Node.js program as a Lambda function.

Page 8: Node.js Code Characteristics

  • Node.js is written in JavaScript, a versatile programming language.

  • Key Difference: Code execution in Node.js occurs outside of HTML context unlike traditional JavaScript.

Page 9: Syntax Standards for JavaScript and Node.js

  • Syntax Rules:

    • Case-sensitive.

    • Statements end with semicolons.

    • Whitespace is ignored.

  • Variable Naming Rules:

    • Can contain letters, numbers,underscore, and dollar sign. Cannot start with a number.

    • Follow case sensitivity and cannot use reserved words.

  • Variable Naming Conventions:

    • Use meaningful variable names.

    • Common conventions: camelCase (e.g., orderTotal) or underscore (e.g., order_total).

  • Data Types:

    • Number: salesTax = .07

    • String: custName = "Acme Anvils"

    • Boolean: endOfOrder = true

Page 10: Setting Up Lambda Function

  • Steps to establish a workspace in AWS Lambda.

Page 11: JavaScript Function Return

  • This function returns a response in JSON format with two elements: statusCode and body.

Page 12: Executing the Function

  • Use the "Test" button to run the Lambda function.

  • First execution requires creating a test event.

Page 13: Test Response Analysis

  • Observational learning: Check if statusCode and body values match the specified outputs in the JavaScript function.

Page 14: Code Modification Process

  • Modify function code.

  • Deploy the changes and conduct testing for immediate feedback.

Page 15: Conditional Logic Syntax

  • Syntax Structure:

    • if (condition) { statements }

    • Includes optional else if and else branches.

  • Example:

    • if (age >= 18) { console.log('You may vote.'); }

Page 16: Operators in Node.js

  • Comparison Operators:

    • ==, !=, >, <, >=, <=, &&, ||, !

  • Arithmetic Operators:

    • +, -, *, /, % for calculations and operations.

  • String Operations: Concatenation examples provided.

Page 17: Experimentation with Variables

  • Discussion prompt: What happens if you alter the age variable?

Page 18: Lambda Versus HTML Code

  • Comparison of Lambda function code with similar embedded JavaScript code in an HTML page.

  • Highlights differences in structure and execution.

Page 19: Further Variable Manipulation

  • Discuss implications of changing the variable in the Lambda function.

Page 20: Another Lambda vs HTML Comparison

  • Further comparison showing differences in conditional logic for embedding in HTML.

Page 21: Loop Example Discussion

  • Engage students with a question about loop variable manipulation.

Page 22: Logging in Lambda

  • Utilize console logs for debugging.

  • Compare uses of response objects vs console output in function applications.

Page 23: Using Node.js Packages

  • Introduction to AWS packages and community libraries within Node.js.

  • Discuss how to implement additional libraries via ZIP upload to Lambda.

Page 24: Class Activity Overview

  • Task: Write and test Lambda functions using Node.js with given examples.

  • Walkthrough of creating a simple currency calculator in Lambda.