Skip to content

Conversation

@chelproc
Copy link
Contributor

@chelproc chelproc commented Jul 20, 2025

フォームの代わりにFetch APIを中心にするように変更しました。

変更の経緯および、章立てについての議論は、#856 を参照してください。
関連する確認問題および演習問題についての議論は、#857 を参照してください。

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 20, 2025

Deploying utcode-learn with  Cloudflare Pages  Cloudflare Pages

Latest commit: e03549f
Status: ✅  Deploy successful!
Preview URL: https://276e51b6.utcode-learn.pages.dev
Branch Preview URL: https://insert-fetch-api-into-web-se.utcode-learn.pages.dev

View logs

@chelproc chelproc force-pushed the insert-fetch-api-into-web-server-chapter branch from 252826b to eda251f Compare July 21, 2025 12:55
chelproc and others added 2 commits July 21, 2025 22:32
- Changed Exercise 1 from Nikkei stock price to exchange rate display
  - Uses top-level fetch without button (immediate page load)
  - Generates random exchange rate between 140-160 yen/dollar

- Changed Exercise 2 from real-time stock updates to currency converter
  - Added input field for JPY amount with button-triggered conversion
  - Removed setInterval functionality
  - Added async/await usage warning with examples

- Updated all sample files to use .mjs extension and type="module"
- Renamed sample directories:
  - nikkei-simple → exchange-rate
  - nikkei-realtime → currency-converter

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@chelproc chelproc marked this pull request as ready for review July 22, 2025 12:54
@chvmvd
Copy link
Contributor

chvmvd commented Aug 1, 2025

確認問題と演習問題を追加しました。また、一部の章のタイトルを仮で作りました。データベースの章の演習問題についてもFetch APIを中心に書き換えました。

@chvmvd
Copy link
Contributor

chvmvd commented Aug 2, 2025

説明文中での明らかな誤植については、説明文中の誤植を修正のコミットで修正させていただきました。
CodeSandboxが動いていないことに伴う対応についてもCodeSandboxが動かない問題を修正のコミットで修正させていただきました。
それ以外のものについては、↑にコメントさせていただきました。

@chvmvd
Copy link
Contributor

chvmvd commented Aug 3, 2025

確認問題と演習問題の修正についてもすべて対応が完了しました。

@chvmvd chvmvd changed the title ウェブサーバーの章に Fetch API を追加 フォームではなく、Fetch APIを中心にするように変更 Aug 9, 2025
@chelproc chelproc merged commit 83165fe into main Aug 9, 2025
3 checks passed
@chelproc chelproc deleted the insert-fetch-api-into-web-server-chapter branch August 9, 2025 13:07
@chvmvd chvmvd mentioned this pull request Aug 9, 2025
4 tasks
@chvmvd chvmvd requested a review from Copilot August 10, 2025 05:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR shifts the curriculum structure to focus on Fetch API for client-server communication rather than traditional HTML forms. It removes the form-based approach and replaces it with modern JavaScript-based Fetch API patterns for both data retrieval and submission.

  • Removes the traditional form-based chapters and examples
  • Introduces Fetch API for data retrieval and data submission as separate chapters
  • Updates the advanced section by removing the separate Fetch API chapter (now covered in the web-servers section)

Reviewed Changes

Copilot reviewed 83 out of 135 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/components/Term/definitions.js Updates chapter navigation paths to reflect new Fetch API-focused structure
docs/4-advanced/01-fetch-api/index.mdx Removes the advanced Fetch API chapter (content moved to web-servers section)
docs/3-web-servers/06-fetch-api/index.mdx New chapter focusing on data retrieval using Fetch API
docs/3-web-servers/07-fetch-api-post/index.mdx New chapter focusing on data submission using Fetch API
docs/3-web-servers/06-form/index.mdx Removes the traditional form-based chapter
docs/3-web-servers/07-get-post/index.mdx Removes the GET/POST request chapter focused on forms
docs/3-web-servers/08-database/index.mdx Updates database examples to use Fetch API instead of forms
Files not reviewed (14)
  • docs/3-web-servers/06-fetch-api/_samples/currency-converter/package-lock.json: Language not supported
  • docs/3-web-servers/06-fetch-api/_samples/exchange-rates/package-lock.json: Language not supported
  • docs/3-web-servers/06-fetch-api/_samples/fetch-open-status-json/package-lock.json: Language not supported
  • docs/3-web-servers/06-fetch-api/_samples/fetch-open-status/package-lock.json: Language not supported
  • docs/3-web-servers/06-fetch-api/_samples/fetch-weather-json/package-lock.json: Language not supported
  • docs/3-web-servers/06-fetch-api/_samples/fetch-weather/package-lock.json: Language not supported
  • docs/3-web-servers/06-form/_samples/node-emoji-form/package-lock.json: Language not supported
  • docs/3-web-servers/06-form/_samples/send-data-to-server/package-lock.json: Language not supported
  • docs/3-web-servers/07-fetch-api-post/_samples/bank-account/package-lock.json: Language not supported
  • docs/3-web-servers/07-fetch-api-post/_samples/book-search/package-lock.json: Language not supported
  • docs/3-web-servers/07-fetch-api-post/_samples/chat-app/package-lock.json: Language not supported
  • docs/3-web-servers/07-fetch-api-post/_samples/coffee-sales/package-lock.json: Language not supported
  • docs/3-web-servers/07-get-post/_samples/post-request/package-lock.json: Language not supported
  • docs/4-advanced/01-fetch-api/_samples/send-post-request/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

docs/3-web-servers/07-fetch-api-post/_samples/chat-app/main.mjs:14

  • [nitpick] Consider using response.status(201).send() or response.status(204).send() to indicate successful POST request completion with appropriate HTTP status codes. Status 201 indicates resource creation, while 204 indicates successful request with no content to return.
  response.send();

app.post("/send", async (request, response) => {
await client.post.create({ data: { message: request.body.message } });
response.redirect("/");
response.send();
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using response.status(201).send() or response.status(204).send() to indicate successful POST request completion with appropriate HTTP status codes. Status 201 indicates resource creation, while 204 indicates successful request with no content to return.

Suggested change
response.send();
response.status(201).send();

Copilot uses AI. Check for mistakes.
const account = { balance: 100000 };
app.post("/transaction", (request, response) => {
// リクエストボディはrequest.bodyに格納される
account.balance += request.body.amount;
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This banking operation lacks input validation. Consider validating that request.body.amount is a number and implementing business logic to prevent negative balances or unreasonable transaction amounts for a more realistic banking application.

Suggested change
account.balance += request.body.amount;
const amount = request.body.amount;
// Validate amount: must be a number, not NaN, finite, reasonable, and not cause negative balance
if (
typeof amount !== "number" ||
!Number.isFinite(amount) ||
isNaN(amount) ||
Math.abs(amount) > 1000000 || // Example: limit transaction to ±1,000,000
account.balance + amount < 0
) {
return response.status(400).json({ error: "Invalid transaction amount." });
}
account.balance += amount;

Copilot uses AI. Check for mistakes.
app.post("/send", async (request, response) => {
await client.post.create({ data: { message: request.body.message } });
response.redirect("/");
response.send();
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for database connections and operations. In production code, you should handle potential Prisma client connection failures and database operation errors gracefully.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants