Skip to content

Conversation

chelproc
Copy link
Contributor

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Aug 11, 2025

Deploying utcode-learn with  Cloudflare Pages  Cloudflare Pages

Latest commit: 15e1d16
Status: ✅  Deploy successful!
Preview URL: https://33f779b4.utcode-learn.pages.dev
Branch Preview URL: https://rewrite-cookie.utcode-learn.pages.dev

View logs

@chelproc chelproc requested a review from chvmvd September 20, 2025 07:05
@chelproc chelproc marked this pull request as ready for review September 20, 2025 07:05
@chvmvd chvmvd requested a review from Copilot September 26, 2025 14:19
Copy link

@Copilot 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 rewrites the Cookie section of the documentation to improve its structure and provide a more comprehensive guide to authentication in web applications. The changes focus on reorganizing content to better explain cookies in the context of authentication systems.

Key changes include:

  • Complete restructuring of the Cookie documentation with new authentication-focused content
  • Addition of new term definitions for HTTP status codes and method terminology updates
  • Addition of comprehensive sample applications demonstrating cookie-based authentication

Reviewed Changes

Copilot reviewed 16 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/Term/type-map.js Adds mapping for HTTP status code term
src/components/Term/definitions.js Updates HTTP method name and adds status code definition
docs/4-advanced/01-cookie/index.mdx Complete rewrite focusing on authentication with cookies
docs/4-advanced/01-cookie/_samples/ New sample applications for cookie counter and authentication
docs/3-web-servers/07-fetch-api-post/index.mdx Updates status code reference to use new term
.vscode/settings.json Adds Prisma formatter configuration
Files not reviewed (2)
  • docs/4-advanced/01-cookie/_samples/cookie-counter/package-lock.json: Language not supported
  • docs/4-advanced/01-cookie/_samples/simple-authentication/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

app.get("/", (request, response) => {
// Cookieの値は文字列なので数値に変換が必要
const count = parseInt(request.cookies.count) || 0;
const count = Number.parseInt(request.cookies.count) || 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

変更前からそうなっているので申し訳ないのですが、このような論理和演算子や論理積演算子の使い方は、「React」の節ではじめて扱うので、この時点では未履修となっています。

このプログラムは、`age`変数が`18`以上である場合のみメッセージを表示します。これは、`&&`演算子の挙動を利用した手法です。これまで、`&&`演算子は両辺が`true`であれば`true`を返す演算子であるとしてきました。しかしながら、[`&&`演算子のより一般的な定義](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Logical_AND)は、**左辺が[<Term>truthy</Term>](https://developer.mozilla.org/ja/docs/Glossary/Truthy)であれば右辺の値を、そうでなければ左辺の値を返す演算子**です。

@chvmvd chvmvd mentioned this pull request Sep 28, 2025
7 tasks
@chvmvd chvmvd requested a review from Copilot October 5, 2025 03:06
Copy link

@Copilot 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

Copilot reviewed 17 out of 30 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • docs/4-advanced/01-cookie/_samples/cookie-counter/package-lock.json: Language not supported
  • docs/4-advanced/01-cookie/_samples/simple-authentication/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


`/login`は、IDとパスワードを含むJSON形式のPOSTリクエストを受け取り、データベースの`User`テーブルのデータと比較することで、認証情報が正しいかどうかを検証します。正しければ、[`crypto.randomUUID`関数](https://developer.mozilla.org/ja/docs/Web/API/Crypto/randomUUID)を用いてランダムな文字列を生成し、新しいレコードを`Session`テーブルに作成した上で、Cookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。

新しいレコードを`Session`テーブルに作成し、その`sessionId`をCookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

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

This sentence appears to be duplicated content from the previous paragraph (line 114). The first part repeats information already explained, making the documentation redundant.

Suggested change
新しいレコードを`Session`テーブルに作成し、その`sessionId`をCookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@chvmvd chvmvd left a comment

Choose a reason for hiding this comment

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

ありがとうございます。
後は、ここだけだと思います。

Comment on lines 114 to 116
`/login`は、IDとパスワードを含むJSON形式のPOSTリクエストを受け取り、データベースの`User`テーブルのデータと比較することで、認証情報が正しいかどうかを検証します。正しければ、[`crypto.randomUUID`関数](https://developer.mozilla.org/ja/docs/Web/API/Crypto/randomUUID)を用いてランダムな文字列を生成し、新しいレコードを`Session`テーブルに作成した上で、Cookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。

新しいレコードを`Session`テーブルに作成し、その`sessionId`をCookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。
Copy link
Contributor

Choose a reason for hiding this comment

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

文章に重複が見られます。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

すみません・・・・

}
```

`/login`は、IDとパスワードを含むJSON形式のPOSTリクエストを受け取り、データベースの`User`テーブルのデータと比較することで、認証情報が正しいかどうかを検証します。正しければ、[`crypto.randomUUID`関数](https://developer.mozilla.org/ja/docs/Web/API/Crypto/randomUUID)を用いてランダムな文字列を生成し、新しいレコードを`Session`テーブルに作成した上で、Cookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。
Copy link
Contributor

Choose a reason for hiding this comment

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

ここでの「ランダムな文字列」とPrisma Schemaに書かれている「一意でランダムなID」が同じものを指しているということが少しわかりにくいのかなと思いました。
つまり、crypto.randomUUID関数で生成されたランダムな文字列が、「一意」であるということが初学者には非自明ではないかと思いました。
crypto.randomUUID関数を用いて一意でランダムなIDを生成し」などでもよいのかなと。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

確かに!ありがとうございます🙇🙇🙇

@chelproc chelproc requested a review from chvmvd October 13, 2025 12:19
Copy link
Contributor

@chvmvd chvmvd left a comment

Choose a reason for hiding this comment

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

ありがとうございます!

@chvmvd chvmvd merged commit cceb0dd into main Oct 13, 2025
3 checks passed
@chvmvd chvmvd deleted the rewrite-cookie branch October 13, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants