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:
Guy Bianco IV
2021-07-01 15:39:50 -04:00
committed by GitHub
parent 0ce74443fc
commit 577bdfb1d6
14 changed files with 1785 additions and 43 deletions

30
todo-ssr/index.js Normal file
View 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);
});