comp review todo app update (#146)
* new todo frontend * yarn --> npm * basic Dockerfile * add Helm chart for todo list * backend working * connect new-app'd frontend to backend via proxy_pass * move nginx conf * move nginx conf back * move helm chart to course repo * add simple SSR node.js service * log error message * fix host typo * fix dockerfiles * add link to items page * improve probe route for todo-backend * canary probe route for todo-backend * Dockerfile -> Containerfile todo-backend * Dockerfile -> Containerfile todo-frontend * remove commands for containerfile as part of comp review
This commit is contained in:
104
todo-ssr/.gitignore
vendored
Normal file
104
todo-ssr/.gitignore
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
1
todo-ssr/README.md
Normal file
1
todo-ssr/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# todo-ssr
|
||||
30
todo-ssr/index.js
Normal file
30
todo-ssr/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const express = require("express");
|
||||
const axios = require("axios");
|
||||
|
||||
const port = Number(process.env.PORT || 8080);
|
||||
const apiHost = process.env.API_HOST || "localhost:3000";
|
||||
|
||||
const app = express();
|
||||
|
||||
app.set("view engine", "pug");
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.render("index", { title: "Hello", message: "Page message" });
|
||||
});
|
||||
|
||||
app.get("/items", async (req, res) => {
|
||||
try {
|
||||
const items = await axios
|
||||
.get(`${apiHost}/api/items`)
|
||||
.then((response) => response.data);
|
||||
console.log("items:", items);
|
||||
res.render("items", { items });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
res.status(500).send(err.message);
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log("Express server started on port: " + port);
|
||||
});
|
||||
1582
todo-ssr/package-lock.json
generated
Normal file
1582
todo-ssr/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
todo-ssr/package.json
Normal file
16
todo-ssr/package.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "todo-ssr",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"express": "^4.17.1",
|
||||
"pug": "^3.0.2"
|
||||
}
|
||||
}
|
||||
6
todo-ssr/views/index.pug
Normal file
6
todo-ssr/views/index.pug
Normal file
@@ -0,0 +1,6 @@
|
||||
html
|
||||
head
|
||||
title= title
|
||||
body
|
||||
h1= message
|
||||
a(href="/items") To Do List
|
||||
11
todo-ssr/views/items.pug
Normal file
11
todo-ssr/views/items.pug
Normal file
@@ -0,0 +1,11 @@
|
||||
html
|
||||
head
|
||||
title Todo Items
|
||||
body
|
||||
h1 Todo List
|
||||
p Note that this version is non-interactive
|
||||
ul
|
||||
each item in items
|
||||
li
|
||||
input(type="checkbox" disabled="disabled" checked=item.done ? "checked" : "")
|
||||
span= item.description
|
||||
Reference in New Issue
Block a user