Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node JS for Architects Part 1

Node JS for Architects Part 1

An introduction to NodeJS and the basics associated with it.

Allan Chua

March 18, 2022
Tweet

More Decks by Allan Chua

Other Decks in Technology

Transcript

  1. NodeJS
    for Architects
    PART 1
    By Allan Chua

    View Slide

  2. Agenda
    How NodeJS
    works
    Tooling Building scripts
    like a boss
    Pre-requisites

    View Slide

  3. Series of topics
    NodeJS
    Scripting
    1
    Frontend
    Engineering React
    2
    API
    Development
    3
    Hosting static
    frontends in AWS
    4
    hosting APIs
    in AWS
    5
    Containers in
    AWS
    6
    Serverless
    APIs for AWS
    7
    Storing data in
    AWS
    8

    View Slide

  4. Goal of Training
    Convert you to
    Solution Architects
    With skills in
    nodejs and AWS

    View Slide

  5. Pre-requisites
    Things that you need before you can work like a ninja in NodeJS

    View Slide

  6. Linux is recommended
    Any linux distro
    is fine
    But ubuntu is highly
    recommended because
    of its compatibility
    with major Ides
    If you are in windows,
    There’s a solution for that
    and it’s called windows
    subsystems for linux
    Macbook pro is the most
    loved machine by developers
    but its very expensive.

    View Slide

  7. Shell skill is a must
    Its almost impossible to Create automation
    pipelines and deploy NodeJS without having a
    decent shell skill.

    View Slide

  8. You’ll need a code editor and a
    browser of course
    IDE & Browser

    View Slide

  9. How node JS works

    View Slide

  10. JavaScript
    Originally Written
    for the Browsers
    But now works
    everywhere

    View Slide

  11. NODE JS Is a runtime
    responsible for executing JS
    outside a browser

    View Slide

  12. But how?
    If JS was made for browsers,
    how was it able to execute js
    everywhere?

    View Slide

  13. Thanks to v8
    V8 is google chrome’s
    javascript engine

    View Slide

  14. How v8 works
    It is used by nodejs to take
    javascript and execute it outside a
    browser.
    machine executable
    code
    V8 translates takes js
    as input

    View Slide

  15. Server and client delta
    But there’s a difference between server and
    browser code
    • DOM
    • Cookies
    • Document
    • Window
    • APIs related to
    browser window
    • File system
    • EXECUTE Shell
    • Web servers and clis
    Browser Node JS

    View Slide

  16. Why NodeJS

    View Slide

  17. Asynchronous = Efficiency
    NodeJS is awesome because it
    enables superior use of
    compute resources in a server
    READ THIS GUYS:
    https://www.geeksforgeeks.org/why-node-js-is-a-single-threaded-language/

    View Slide

  18. Single Language means
    happy owners
    - Less cognitive switch
    - Faster onboarding of
    developers
    - Faster engineering

    View Slide

  19. Could be used to make
    And many more
    Web ApiS websites Artificial
    Intelligence

    View Slide

  20. Largest programming ecosystem
    The large ecosystem of nodejs applications can easily
    result to reduction of engineering cost
    Stackoverflow Sample
    Projects
    Youtube
    Videos
    Medium
    Articles

    View Slide

  21. Tooling

    View Slide

  22. Core Tools
    NVM NPM NPX
    We’ll view tackle this on frontend
    and api development portions

    View Slide

  23. NVM
    Stands for
    NODE VERSION MANAGER.
    Installation Script

    View Slide

  24. NVM
    It’s shell-based cli tool used for managing the
    active version of nodeJs installed in your
    machine.

    View Slide

  25. NVM
    View all
    available versions
    download
    versions
    Switch Between
    versions

    View Slide

  26. NVM
    View all available
    versions

    View Slide

  27. NVM
    List versions with
    long term support

    View Slide

  28. NVM
    Use a Specific
    Version

    View Slide

  29. NPM
    Stands for
    NODE package MANAGER.

    View Slide

  30. NPM – Package Manager
    Open source
    Repository of
    packages
    Configuration
    like version, and
    type
    Package
    management
    Run and
    Manage Scripts

    View Slide

  31. Installed together
    with NodeJS

    View Slide

  32. NPM - Verify
    Verify NPM’s existence

    View Slide

  33. NPM
    Can also refer to:
    The open source repository of javascript
    packages
    https://www.npmjs.com/

    View Slide

  34. The nodejs developer
    workflow

    View Slide

  35. The nodejs development workflow
    Install
    dependencies
    Initialize your
    project
    Write your
    code
    Execute
    application
    entry point

    View Slide

  36. Let’s rock and roll

    View Slide

  37. Let’s build an
    avatar generator
    in 5 minutes

    View Slide

  38. If you want to try
    it out later after the session
    https://github.com/allanchua101/avatar-generator

    View Slide

  39. Let’s setup a project

    View Slide

  40. Type all this code guys
    GENERATE-AVATAR.JS

    View Slide

  41. Run the code

    View Slide

  42. Let’s beautify our output
    Install colors package using the code above

    View Slide

  43. Update our javascript logging code
    Let’s utilize colors to sprinkle
    creativity on our logs

    View Slide

  44. Results
    Before change and after ^_^

    View Slide

  45. Let’s go crazier and make
    graffiti out of the text

    View Slide

  46. Update our Code again

    View Slide

  47. Sweet graffiti in your
    logs

    View Slide

  48. Challenge
    for this week

    View Slide

  49. Homework
    - I would strongly suggest using dual
    boot and have ubuntu as the 2nd boot
    system of your pCs
    - If you are in windows and you love it,
    setup WSL
    - Install Node JS
    - Install NVM

    View Slide

  50. Homework 1
    Create a NODE JS script that can convert EXCEL
    files to JSON and save it on the disk

    View Slide

  51. Homework 2
    Create a NODE JS script that can convert JSON files
    to EXCEL and save it on the disk

    View Slide

  52. Homework 3
    Create a NODE JS script that can add a background
    image to a transparent PNG file and save it on the
    disk

    View Slide

  53. Homework 4
    Create a NODE JS script that generates a QR code
    for a website and save it on the disk

    View Slide

  54. Homework 5
    Create a NODE JS script that generates a barcode
    based on the provided product ID and save it on the
    disk

    View Slide

  55. Homework 6
    Create a NODE JS script that retrieves data from movie list
    API and generate an excel file from it. Use this package:
    https://www.npmjs.com/package/movie-list-node

    View Slide

  56. Next Week
    We will take a look
    at each of your
    outputs and

    View Slide

  57. Next Session
    We will look into frontend development using React JS

    View Slide