Skip to content

Commit 3d40e8f

Browse files
authored
Merge pull request #529 from ut-code/fix-db-answer
Fix answer of database
2 parents 46822a0 + 31f0493 commit 3d40e8f

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

docs/3-web-servers/07-database/_samples/forum/main.mjs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import express from "express";
2-
import { readFileSync } from "fs";
3-
import ejs from "ejs";
42
import { PrismaClient } from "@prisma/client";
53

64
const app = express();
@@ -13,11 +11,24 @@ app.get("/", async (request, response) => {
1311
const messages = await (
1412
await client.forum.findMany()
1513
).map((data) => data.message);
16-
const template = readFileSync("template.ejs", "utf-8");
17-
const html = ejs.render(template, {
18-
messages: messages,
19-
});
20-
response.send(html);
14+
response.send(`
15+
<!doctype html>
16+
<html lang="ja">
17+
<head>
18+
<meta charset="utf-8" />
19+
<title>Title</title>
20+
</head>
21+
<body>
22+
<ul>
23+
${messages.map((message) => `<li>${message}</li>`).join("")}
24+
</ul>
25+
<form method="post" action="/send">
26+
<input placeholder="ここに入力してください。" name="message" />
27+
<button>送信</button>
28+
</form>
29+
</body>
30+
</html>
31+
`);
2132
});
2233

2334
app.post("/send", async (request, response) => {

docs/3-web-servers/07-database/_samples/forum/template.ejs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)