378 views
My blog for Full Stack Web Development === ## Introduction My name is Lee C. Degeilh. I enrolled H2C program at Kajaani AMK in 2020 autumn. Here is the link to my projects in KAMK: https://gitlab.dclabra.fi/Lee-Lilly So far I have completed DevOps and Cybersecurity (1 & 2), and currently work on Full-stack web development and Embedded Python in IoT technology. ## Module 1 - Introduction to web development ### A Simple Web Server Some new knowledge about Node.js are presented in the course material of [Full Stack Web Development](https://devmoodle.kamit.fi/course/view.php?id=2799#section-1), yet starting simply with "Hello World". ### DevTools used - Node.js (an open-source javascript runtime environment https://nodejs.org) - Node is useful for developing applications that require a persistent connection from the browser to the server and is often used for real-time applications such as chat, news feeds and web push notifications. - Express.js (a Node.js framework with HTTP utility methods and middlewares https://expressjs.com/) ### Gitlab - create a project Since I already have an account in https://gitlab.dclabra.fi (with KAMK.fi credential), and established SSH authentication, what I need to do is to create a new project, named as "Simple Web Server with Node.js and Express.js". The details of established SSH authentication check my blog in https://gitlab.dclabra.fi/wiki/s/SkKDxfkUw. Create a local folder for our project. > mkidr FullStack > cd FullStack Clone the remote repository to local repository. > git clone git@gitlab.dclabra.fi:Lee-Lilly/simple-webserver-with-node.js-and-express.js.git > cd simple-webserver-with-node.js-and-express.js > touch README.md ### NodeJs initiation Node.js project should have package.json file, a kind of receipt for our project, where we define name, version, dependencies, route and other critical information. Use following command to initiate the project, which generates package.json file for us. > npm init The command will prompt different questions like name, version etc. Just simply accept the default values for all fields. After the command is invoked, we have package.json file in our repository folder. > code . Open the repository folder with VSCode to edit package.json file (https://gitlab.dclabra.fi/wiki/s/S19LWaSFP#), and save. Create our main javascript file and we name it "server.js". ![](https://gitlab.dclabra.fi/wiki/uploads/upload_69118679c6d6ab4d5158670515702292.png) ### Express - create a server instance Install the Express under the repository folder. > npm install express --save In file package.json, "express" is added to the field of "dependencies" with version info. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_b96d9d359fb177a5b4c22adfe3f85b9d.png) Edit server.js file (https://gitlab.dclabra.fi/wiki/s/S19LWaSFP#) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_299f4c4c3062b7931914d15b66e3e8bf.png) Run app locally, use following command in VS terminal. > npm start ![](https://gitlab.dclabra.fi/wiki/uploads/upload_c45f09f13ad0580335f7110529b4b380.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_50fef99f90097113fb9d4ce00a483574.png) ### Docker About Docker, questions like "What is docker?", "How to docker?", please refer to my blog of ***Docker for DevOps*** on gitlab wiki https://gitlab.dclabra.fi/wiki/s/SkKDxfkUw# Somehow, in that blog, the docker installation was missing. We can give more details here. ### Docker Installation Docker Engine for Windows can be downloaded from https://hub.docker.com/editions/community/docker-ce-desktop-windows/. Enable ***Windows SubSystem for Linux*** and ***Virtual Machine Platform*** in the "*Control Panel*" -> "*Progaram*" -> "*Turn on/off features*", which permits virtualization of a subsystem on Windows, often used for running Linux on Window. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_7ca0404f7469a895b9a1c0295453e136.png) Then **Restart computer** to make features take effective. Since I am using Windows 10 Home version 20H2, I will need to download and intall WSL update patch WSL2 ["wsl_update _x64.msi"](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi). Then set WSL2 as default version use Windows CMD. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_571ed1a1126958a1ffb3808d8a50047b.png) Follow docker intallation wizard, when prompt settings, enable WSL2 backend engine and allow docker run at log in, complete installation and restart computer. Docker appears on Desktop, and use Windows CMD to verify engines. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_5ca22580d7116172239911099073951b.png)![](https://gitlab.dclabra.fi/wiki/uploads/upload_9c4d57206875b2a3dc7f6635408e939b.png) Now everything up and running! ### Docker Run Go to our project folder, create a Dockerfile and edit in VS. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_95464f0e27691deb595f3872c2bef794.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ecf53d925c5a01d8ccf3011cd3486718.png) Write a ".dockerignore" file to prevent local modules and debug logs being copied into docker image. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_06eff6c619ec94cb70554e5c0b493581.png) Build image with > "docker build . --tag test/simple-web-server" ![](https://gitlab.dclabra.fi/wiki/uploads/upload_c71dc58654c4a9b4a71e95519a2881ce.png) Verify the image and run image by projecting local port 3000 to the same port inside the image. > "docker run --name simple-web-server -p 3000:300 test/simple-web-server:latest" ![](https://gitlab.dclabra.fi/wiki/uploads/upload_6dc47568c66150c309eaf14ab73bd862.png) When running the image, a container is generated, get into the container to navigate with Bash shell. > docker container ls -a > ![](https://gitlab.dclabra.fi/wiki/uploads/upload_55756fc85f5809729b6b5e9f2906ee8e.png) > docker exec -it <containerID> /bin/bash > ![](https://gitlab.dclabra.fi/wiki/uploads/upload_14fc1ee7ebc7df2b3827044bd007d087.png) Open the web browser for localhost:3000 ![](https://gitlab.dclabra.fi/wiki/uploads/upload_902baf8ad27f4719b452ce1c5da18068.png) *** ## Module 2 Telnet and Node.js Socket ### Dockerized Telnet communication > ➜ 🐳 docker run -it --name telnet-test ubuntu:18.04 bash > apt update > apt install telnet > telnet irc.quakenet.org 6667 > ![](https://gitlab.dclabra.fi/wiki/uploads/upload_4105ed1a79dc2b903b8629d5cddb1c93.png) After connection to server is etablished, ... ![](https://gitlab.dclabra.fi/wiki/uploads/upload_e07353b99dd422ba8c991575b2536ee8.png) There are many servers on https://www.quakenet.org/servers, they come in random via telnet. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_62197ea67efbbb08a128c5ca71bc32c8.png) Let JOIN a channel on QuakeNet IRC Netwokr via telnet > JOIN #kamk.h2c ![](https://gitlab.dclabra.fi/wiki/uploads/upload_cfdf671dffdcf71c143f1b632b32b3a1.png) We can send a msg to everyone on the channel > PRIVMSG #kamk.h2c :Hello! > PART #kamk.h2c :See you later! > ![](https://gitlab.dclabra.fi/wiki/uploads/upload_5fbf7663e44b5155ad70b7ba532aae2e.png) > QUIT > ![](https://gitlab.dclabra.fi/wiki/uploads/upload_16bb1e318683bab5edcea7a808c786dc.png) The same thing can also be done via https://webchat.quakenet.org ![](https://gitlab.dclabra.fi/wiki/uploads/upload_5169d7c2352df3fb6f32b5fdc9581d0a.png) ### NodeJS net.Socket The net module provides an asynchronous network API for creating stream-based TCP or IPC servers (net.createServer()) and clients (net.createConnection()). A net.Socket can be created by Node.js and passed to the user when a connection is received. For example, a net.Server with socket stream opens on port 8082, and client can connect to the port and send data. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_73ed8cc4725cf8d2e3cc83683f16e703.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_fee015dde9ea7de4ab583fa35676f80c.png) ### Telnet via net.Socket #### **App 1: Echo Server** (https://gitlab.dclabra.fi/Lee-Lilly/tcp-echo-server) - User can connect to the server on port 3000 via telnet protocal. - User can send data to server and server sends it back. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_74442702b226ffbe51a30228acc47ea2.png) #### **App 2: Chat Server** (https://gitlab.dclabra.fi/Lee-Lilly/tcp-chat-server) - User can connect to the server getting a random Id. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_03b234d0bbfa035b40276fa403d7bd52.png) - User can register **an unique username** on the server. If user register a new name, the newer one automatically replaces the older one. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_88424b8941e49c2befa7f7ec71049ce8.png) - User can search for other connected users on the server. -![](https://gitlab.dclabra.fi/wiki/uploads/upload_2eae13b46d08c1675df1b121880c8f51.png) - User can send msg to any single user if user is connected. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_96510a34af813bdc86ca2c12c0a36c09.png) - User can send msg to all connected users. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_7c01b438efd411c9786b8b856f00b349.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_db143e30208c2b34a9f6c9a028924b72.png) ### **Differences between Microsoft telnet and Linux telnet (*own experiences*)** Above picture shows that App 2 runs on Microsoft Telnet, it has some differences from the Linux/Unix telnet. In App 1, the differences is obvious, the socket pipes back each character (keystroke), instead of whole sentence. The major difference is that "RECIEVED DATA" in Microsoft Telnet are **byte by byte** (character by character). ![](https://gitlab.dclabra.fi/wiki/uploads/upload_f0c18f5500007dacbfb9d14cefe7f90e.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a4609f8164d4b90cb70639a6f7bc2e7b.png) The following code adds the character together, push them to the command array only when keyboard hit is "space" or "return". ![](https://gitlab.dclabra.fi/wiki/uploads/upload_677061cf62e27e00a2d6ee8d13f92307.png) The Microsoft Telnet seems very clumsy. Any key stroke is recorded, and can only backspace and edit in "insert" mode. **Questions:** 1. Is Microsoft Telnet represents the original manner of data receiving and sending of net.Socket, and Linux Telnet has implemented inner mechanism to re-construct the bytes? I remember that during a cybersecurity course, playing as a middle-man to catch the data sent btw the server and the client via Telnet or SSH without using key-pair, I saw data came byte by byte (character by character). 2. If Docker is for dev purpose and totally in Linux environment, the developer may not notice the differences between the two systems. Is this sufficient for releasing a fully-trusted product, knowing that most PC users are based on Windows? *** ## Module 3 MongoDB and NodeJS - **mongoDB**: MongoDB is a cross-platform and open-source document-oriented database, a kind of NoSQL database. As a NoSQL(not only SQL) database, MongoDB shuns the relational database’s table-based structure to adapt JSON-like documents that have dynamic schemas which it calls BSON(Binary JSON). - **mongodb**: the official mongoDB driver for NodeJS. - **mongooseJS**: Basically, it is a package that we will use to interact(query, update, manipulate) with our MongoDB database in our nodeJS app. We would install or ‘require’ mongooseJS in our app with NPM(node packaging manager). ### App: president **Prerequesites** - Run MongoDB Service 1. Install MongoDB on Windows run the service **OR** 2. Dockerizing MongoDB run in Linux ubuntu - NPM init and install dependencies (see *package.json*) > npm init > ... > npm install mongodb > npm install mongoose > ![](https://gitlab.dclabra.fi/wiki/uploads/upload_4663b1fc5fcf731ffea060460b9abc4a.png) - Create a database with MongoDB If the MongoDB is installed on Windows, and MongoDB service is running, you may find desktop MongoDB management application **MongoDB Compass**. We can use it to create a database on **localhost:27017** (the *default port* running MongoDB Service locally), and populate the database with imported JSON file. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_634912ecb2e6851bf6e9ae756b5c60ee.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_20e7f7ced2cca06ec433dc5a076eb9bd.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_f26cb0d27aa6d818fe790002bcd8dfeb.png) **Connect MongoDB to App** Connect MongoDB with Node JS, we need *Mongoose* package, and call *connect()* function and passes MongoDB Database URI as argument to the function. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ed3495d2f29323f21cda93c27e959554.png) and run the app file **server.js** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_2bfdc80ac4f8ac257f031313c781dc93.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_0dc9939dcd2ed4c4911bfada86c3fa4d.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a90b5a1985ff3068a41c07f1b70a73a4.png) Then go on "**localhost:8080**", press "***load presidents***" ![](https://gitlab.dclabra.fi/wiki/uploads/upload_fbbd8405f942d636db18d3027b0c0247.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_57430e7e3c8af1b37d2669fd71b97efa.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_1b194f6386d912593c6e2781b0f5afbf.png) ### Dockerizing all services We have a **docker-compose.yml** file placed in the project root directory "**/presidents**", which "**glues**" the database and the server together. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_79641d456df7fbd6bdfe34ee816c5196.png) According to defined services in the *docker-compose*, we need to change **localhost** to the named service on both database.js and server.js. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_7664fc220622df5954e09bbecd3cd934.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_6e850f8075ee71bc8ccb24c33be1ea99.png) **Build and Run the docker containers** - **Step 1:** Go to project root "/presidents", build all services. Magic action! :+1: > docker-compose up --build ![](https://gitlab.dclabra.fi/wiki/uploads/upload_7087386397032c012d65fc2ead617c56.png) - **Step 2:** Open *Docker Desktop*, check on "presidents" (**president-network**), it shows three containers are running, if we are lucky. :+1: ![](https://gitlab.dclabra.fi/wiki/uploads/upload_e734647f3b7678e44391921d2448e000.png) Now browse to locahost:8080 and press "load presidents", we get only the table headers, without data. So we need to put real data into MongoDB. - **Step 3:** Populate data to database. We have another Dockerfile placed in the directory of "**/utilities**", which **does two things**: - copy data file "president.json" to the container. - install "curl" tool that would be used to populate the JSON data. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_4ee2b1c15bd4165a39fe81e60e94a299.png) go to container "president-utilites" with CLI ![](https://gitlab.dclabra.fi/wiki/uploads/upload_0656b3470da8992e2e55d639fad8b597.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_b02bf82866c83a3ded04cd8e5c3d534c.png) Now, the web "localhost:8080" loads up all presidents data. Bravo! :+1: ![](https://gitlab.dclabra.fi/wiki/uploads/upload_4377423bba1785f2ba5b82815af7cffe.png) *** ## Module 4 Brief on Vue JS ### What is Vue JS? Vue is a **progressive** JavaScript framework for **Single Page Application (SPA)**, or can be used to create stand-alone widgets, e.g., signup form. Other equivalent frameworks are REACT and Angular. In many aspects, they share similar concepts, e.g. **properties and states, props and components, etc.**. In contrast to Angular and React which are in huge part determined by Google and Facebook, **Vue was created by a single person - Evan You.** **Vue is open-source** (circulated under the **MIT license**) and driven generally by its community. ### What is SPA? - Only the first page is entirely loaded from server to broswer in response to the user request. - Vue intercepts the subsequent requests and handles the **routing in the browser**. - The web page is dynamically rewritten with new data from the web server, instead of reloading an entire page to the browser. - Results in a much faster and smoother website experiences. ### Vue Js and PWA - **PWA**, stands for [Progressive Web App development.](https://www.freecodecamp.org/news/practical-tips-on-progressive-web-app-development/#:~:text=In%20the%20simplest%20terms,%20a%20progressive%20web%20app,function%20similarly%20to%20a%20mobile%20or%20desktop%20app..) - Vue JS has **Reactivity system**, which allows fast render, test data on fly in browser. - Vue **core library is focused on the view layer only**, and is easy to pick up and integrate with other libraries or existing projects. *** ## Module 5 Build App with CDN (without bundle) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_38b2186c4ac7905969c0e4e34cbe0428.png) Let's follow [Intro to Vue 3](https://www.vuemastery.com/courses/intro-to-vue-3/class-and-style-binding-vue3), the lecturer summarized the basic features of Vue3 shown as below, and **my solutions to challenges** at end of each session can be found in the **start code** at [Gitlab.dclabra.fi/Lee-Lilly](https://gitlab.dclabra.fi/Lee-Lilly/vue_learning/-/tree/master/Vue_3_Intro_end_codes_and_solutions) ### 1. **How Vue works?** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_0fa75603f31d785328275ee377a84def.jpg) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_15e495d71447795a08999d2fdf3e784e.png) ### 2. **HTML Attributes bind with data** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_55a474da4b7da9b457f39fe7b952d616.jpg) ### 3. **Conditional rendering of data** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_25ec0e73b1843b13f1fcce80fc503d19.jpg) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ad34ad87c2d6f7f40d72d71e2253b920.jpg) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_2b1a18bf80e33c222d3f42feaba1e099.jpg) ### 4. **Render a list of data** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_861c3c0240d1070e457310b1a50e4562.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_445e3f892f398d81189c8783ea132445.jpg) ### 5. **Event listening** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_bf21dfa6450fdc3a80710b125c0c9dc5.jpg) ### 6. **Style binds with data** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ac9c78cd3508238c5553a18c5cfaaafc.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_5868a962b0f7d81aad7906c525db2438.png) ### 7. **CSS class binds with data** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_21a52221c3d5c524afea457d043f2be4.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_36143f4634ea4dfcb458720b408dd3af.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a1da0a514b4464217bc27c5aa33c050d.png) ### 8. **Computed Properties** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_9f04709469eddf5a87267b5259313dea.png) ***property*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_8cad099930eab38e189849fb4a9bceba.png) ***property state change over the course*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_1c16668d754aa62e5edb11cbfc109b52.png) ***computed property*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_b071973ddb76fb3592ccc09a5d484401.png) ***render in html*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_1c87e4d485b5e89586e877cc6a3b6212.png) ### 9. **Components and Props** **Two main characteristics of Vue props:** 1. Props are **passed down** the component tree to descendents (**not up**) 2. Props are **read-only** and cannot be modified. ***index.html*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a53c7f90564a9ac7b678e947228cbf02.png) ***main.js*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a97028c9dd602a7f07c3a5a1ec207541.png) ***productDisplay.js*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_403dd262d83f09a1c817f99c7a9161d4.png) ***template:*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_18ad5b851c5d5de90265a249711480c0.png) ***computed property*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_9ecf9b0c70b39270a86e57ab4934ef28.png) ***productDetails.js*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_224239f94f55f5ce161c3148c3048503.png) ***render in productDisplay as a sub-component*** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_dbcc2ee13c4883fd1093884917bc4287.png) ### 10. **Event emitting** ![](https://gitlab.dclabra.fi/wiki/uploads/upload_830a8c28a3d82e9822ea4ab7b31a55ec.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_2274e25eff7057acd6daa7fd777efa7a.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_88c50c1b99d774f8b1121dcb720d9c9e.png) ### 11. **Two-way data binding** For interactive form, HTML template must be able to bind user input to the App data. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_79bb3cdceae5cc25c67ca42969d525c6.png) ### VS code extensions for Vue app development **Vetur**: supplies Vue JS language features (syntax highlighting, IntelliSense, snippets, formatting) to VS Code. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_dbcd45dc02d7d8b828ea981a913fdca6.png) **Live Server**: extension for VS code, load any HTML page in a development virtual server. Fast for testing views. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a49b8211d0c24eefcce9c47709608e5e.png) ## Vue.js devtool Extension for Chrome and Firefox ![](https://gitlab.dclabra.fi/wiki/uploads/upload_786e6e0d542eabf49a5ccb8311c22afc.png) **Open** "..\Intro-to-Vue-3-final\index.html" in **Live Server**, and **inspect** in Chrome browser. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_2624f01fa602e393998aedd4f59505ff.png) *** ## Module 6 Build Vue App with Webpack bundle ### Installation (using npm or yarn) > npm install vue@next **OR** > npm install -g @vue/cli ### Project creation (using GUI or CLI) > vue ui **OR** > vue create *AnyAppName* ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ec06a3a87911524541e8d92e2f854739.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a0d7d13728628266c930d7a91f91520e.png) ### Basic project structure explained ![](https://gitlab.dclabra.fi/wiki/uploads/upload_7e672094e5310d4f96729a7335f906d2.png) - **public/** : contains *"index.html"* sent to browser initially. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_cb022d05843e98639ada1666f7291a8e.png) - **src/** : contains the application source code. - **./assets/** : images and fonts for app. - **./components/** : building blocks of our Vue app. - **main.js** renders App.vue component (and everything nested within it) and mounts it to the DOM. - **App.vue**: the root component defines the template and style for all nested view components, ![](https://gitlab.dclabra.fi/wiki/uploads/upload_626475c367e210dc4be9f40c53867584.png) *** Follow the **demo of 10 Vue Apps** on https://vue3-full-course.netlify.app/ **My solutions of 8 Vue Apps can be found on** https://gitlab.dclabra.fi/Lee-Lilly/my_vue_app ## App Demo (Part I: Vue 3 features) **Hero list** (user can add a hero name to the display list or remove name from the list) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_471eac60ff4e3074e4c549c6bd48499c.png) *** **Slot content in Modal** (using **slot** to pass different content as parameter for rendering in the same modal, which allows template to be reusable) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_d0f6077ea2f38248bb54548b5c0c53b7.png) *** **Slider** (**router-view** with **named transitions**, which makes animated effect on navigation) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_fa36b5e94fcc060ad14f4e931a13901b.png) *** **Markdown App** (installed ***[vue-markdown-it](https://github.com/JanGuillermo/vue3-markdown-it)*** package to sanitize and transcribe the input text. Reactive feature is implemented by using **template ref**) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_5e28a9b36c9c8de7d4a0adaa3b4fa224.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_3739345dc73fce29cdaf2f7034964ceb.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_93f500b7e2193c6f2d7165cd0a31c386.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ec6345498c04ee9de2019abb8e8451ea.png) *** **Calculator** (Use **grid-column style** to create calculator layout with buttons. Data includes the current display, chosen operator and number. Methods include getting chosen operators and numbers via pressing buttons, also the un-displayed basic math calculations) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_007dd1628e6ae723efa2a1d9d0d1c228.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_4db6645da1e74ac4921c09b88aad3401.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ded9294b4e073e8b90b85e314d40fc69.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_64929d8cbcbf1bac2e860b7afb748147.png) *** **Calendar** (install **[vue-simple-calendar](https://github.com/richardtallent/vue-simple-calendar)**, which shows month, date, year, week days, and back-forth scrolling enabled. We can add event to the calendar, and remove an event by clicking on the calendar and confirm deletion via a dialog) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_f958e63806b6747ec75b0498afa24193.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_44a42a268972fc9c794728835a6348fd.png) ## App Demo (Part II: fullstack with databases) **User Crud** (json-server database and axois http service) - install ***json-server*** as database for json data files, install **axios** for fetching data ![](https://gitlab.dclabra.fi/wiki/uploads/upload_3f7200b77a5bf3cb332b7c916bfc03c5.png) - Test **json-server** and **dataset** in json format (**./src/data/user.json**) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_ab9f3feb8b735485174d3a395dd9decc.png) - Various **table** packages available for Vue, did following try: - Tried to use *[vue-good-table](https://github.com/xaksis/vue-good-table)* package to display user data, but due some feature does not support Vue3, report compile failure. - Installed ***[vue3-table-lite](https://github.com/linmasahiro/vue3-table-lite)*** package to display user data in table. Customize the look in "node_modules/vue3-tabel-lite/src/components/Table.vue" - A good alternative would be **[Vue Material Table](https://vuematerial.io/components/table)**, pagination is coming soon, stay in tune. - Open **json-server**, use asynsc await **axios.get(*'resources'*)** fetching data from 'Resources'. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_40a32d6ac1fb07d370122f6f2745d9bb.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_72c0b880be8b3a8803568f174778ced1.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_bcce11211a274610fab36fff6fb37ac9.png) - Use 'checkbox' API to select 'rowsKey' for deleting multiple users. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_38e2b2c1863cb0c24f3f2cc3c5f93bdd.png) - Get specific user data, send as props to update form ![](https://gitlab.dclabra.fi/wiki/uploads/upload_23fee50be5f4c30aa175c3600f22d262.png) - Update user with updated data ![](https://gitlab.dclabra.fi/wiki/uploads/upload_9654196a8f2ad988a38c87004d4506ec.png) *** **Login** (integrate with firebase authentication and firestore database) - Firebase provides cloud database and login authentication. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_c5cb96f77cf5babc5bdcb91a81934d39.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_25f232e23becfa9bb7012ae9fd432dae.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_0331b2aad6ccb4b22cb95312cad3aad4.png) - Register user authentication with a unique email. - Once user authentication is established, add the user details to firestore database. ![](https://gitlab.dclabra.fi/wiki/uploads/upload_f231689085eb83b0d8bed47adeeaeaf0.png) - Login with firebase authentication ![](https://gitlab.dclabra.fi/wiki/uploads/upload_c407b89d1596afdd652954c963ea9589.png) - Routes: *Login -> Welcome -> Logout* *Register -> Login -> Welcome -> Logout* ![](https://gitlab.dclabra.fi/wiki/uploads/upload_173bf530dbf8f423af33a79a1f033fa7.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a9f6b47057c3daa6f1e60b8974718dfb.png) - Apply authentication gards to Welcome page ![](https://gitlab.dclabra.fi/wiki/uploads/upload_d71f3ef4f520d308d7fccbdbddc338ae.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_f99fa4f824c5c7067f598fd76e1cbe67.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_0cc114b929513aeae22c33c1de281b01.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_58dc0d1fa960577fcb4279c4c0165289.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_a1e9ed15acaf199625ca45dea5a80cef.png) ![](https://gitlab.dclabra.fi/wiki/uploads/upload_24fb781475179c0e048b73d10c56b4c8.png) ## What else to mention? - Options API, Composition API, Reactive API Through the exercises, I always used options API for defining data, props, methods and created for initial state, emit for sending event payload. https://v3.vuejs.org/api/options-api.html Part of Reactive API, such as refs, computed are used in my app. They are light weight and very effective. https://v3.vuejs.org/api/reactivity-api.html The composition API is Vue3 new feature. There is a mapping betweent options API and composition API, such as *created : setup* https://v3.vuejs.org/api/composition-api.html#setup - Vue UI framework There is an article writing an overview of Vue UI framework. https://dev.to/abiolaesther_/an-overview-of-the-top-10-vue-ui-component-libraries-in-2021-3dhm I am interested in ***PrimeVue***, although I get to know it late. It has 80+ UI components and fully support Vue3. https://www.primefaces.org/primevue/showcase/#/ - Vuex It helps to handle state of data outside of the Vue components. Since we build simple apps here, I have not much knowledge about it. https://vuex.vuejs.org/#what-is-a-state-management-pattern