* 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
30 lines
735 B
JavaScript
30 lines
735 B
JavaScript
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);
|
|
});
|