Skip to content

Commit 530ba3c

Browse files
authored
static generation (#649)
# PRの概要 SSR をやめ static export モード (SG) にした 一応別で環境作ってみた ↓ https://coursemate-nbic.onrender.com ## 具体的な変更内容 ## 影響範囲 ## 動作要件 ## 補足 ## レビューリクエストを出す前にチェック! - [ ] 改めてセルフレビューしたか - [ ] 手動での動作検証を行ったか - [ ] server の機能追加ならば、テストを書いたか - 理由: 書いた | server の機能追加ではない - [ ] 間違った使い方が存在するならば、それのドキュメントをコメントで書いたか - 理由: 書いた | 間違った使い方は存在しない - [ ] わかりやすいPRになっているか <!-- レビューリクエスト後は、Slackでもメンションしてお願いすることを推奨します。 -->
1 parent 548e146 commit 530ba3c

File tree

17 files changed

+258
-214
lines changed

17 files changed

+258
-214
lines changed

bun.lock

Lines changed: 80 additions & 57 deletions
Large diffs are not rendered by default.

common/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"name": "common",
3+
"private": true,
4+
"version": "1.0.0",
35
"type": "module",
46
"devDependencies": {
57
"@types/bun": "latest"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "course-mate",
3+
"private": true,
34
"version": "1.0.0",
45
"author": "",
56
"main": "index.js",

render.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Exported from Render on 2025-02-15T11:38:48Z
2+
services:
3+
- type: web
4+
name: CourseMate
5+
runtime: static
6+
repo: https://github.com/ut-code/CourseMate
7+
branch: make-it-ssg
8+
envVars:
9+
- key: BUN_VERSION
10+
sync: false # Render Dashboard https://render.com/docs/blueprint-spec#prompting-for-secret-values
11+
- key: SKIP_INSTALL_DEPS
12+
sync: false
13+
- key: NEXT_PUBLIC_ALLOW_ANY_MAIL_ADDR
14+
sync: false
15+
- key: NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
16+
sync: false
17+
- key: NEXT_PUBLIC_FIREBASE_APP_ID
18+
sync: false
19+
- key: NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
20+
sync: false
21+
- key: NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
22+
sync: false
23+
- key: NEXT_PUBLIC_FIREBASE_PROJECT_ID
24+
sync: false
25+
- key: NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
26+
sync: false
27+
- key: NEXT_PUBLIC_FIREBASE_API_KEY
28+
sync: false
29+
- key: NEXT_PUBLIC_API_ENDPOINT
30+
sync: false
31+
buildCommand: bun install --filter "web" && cd web && bun run build
32+
staticPublishPath: web/out
33+
version: "1"

server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"name": "course-mate",
2+
"name": "server",
3+
"private": true,
34
"version": "1.0.0",
45
"description": "",
56
"main": "src/index.ts",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ImageIcon from "@mui/icons-material/Image";
2-
import { sendImageTo } from "../../api/image";
2+
import { sendImageTo } from "~/api/image";
33

44
import type { DMOverview, SendMessage, UserID } from "common/types";
55
import { parseContent } from "common/zod/methods";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from "next/link";
22
import { MdArrowBack } from "react-icons/md";
3-
import UserAvatar from "../human/avatar";
3+
import UserAvatar from "~/components/human/avatar";
44

55
type Props = {
66
room: {
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
"use client";
2+
3+
import { Box, List, Typography } from "@mui/material";
4+
import type { RoomOverview } from "common/types";
5+
import { useRouter, useSearchParams } from "next/navigation";
6+
import { HumanListItem } from "~/components/human/humanListItem";
7+
import RoomPage from "./RoomPage";
8+
9+
type RoomListProps = {
10+
roomsData: RoomOverview[] | null;
11+
};
12+
13+
export function RoomList(props: RoomListProps) {
14+
const { roomsData } = props;
15+
const router = useRouter();
16+
const searchParams = useSearchParams();
17+
const friendId = searchParams.get("friendId");
18+
19+
const openRoom = (room: Extract<RoomOverview, { isDM: true }>) => {
20+
router.push(`/chat?friendId=${room.friendId}`);
21+
};
22+
23+
return (
24+
<>
25+
{!friendId ? (
26+
<List disablePadding>
27+
<p
28+
style={{
29+
marginLeft: "40px",
30+
marginRight: "40px",
31+
}}
32+
>
33+
{roomsData && roomsData.length === 0 && (
34+
<>
35+
誰ともマッチングしていません。
36+
<br />
37+
リクエストを送りましょう!
38+
</>
39+
)}
40+
</p>
41+
{roomsData?.map((room) => {
42+
if (room.isDM) {
43+
if (room.matchingStatus === "otherRequest") {
44+
return (
45+
<Box
46+
key={room.friendId}
47+
onClick={(e) => {
48+
e.stopPropagation();
49+
openRoom(room);
50+
}}
51+
>
52+
<HumanListItem
53+
key={room.friendId}
54+
id={room.friendId}
55+
name={room.name}
56+
pictureUrl={room.thumbnail}
57+
rollUpName={true}
58+
lastMessage={room.lastMsg?.content}
59+
statusMessage="リクエストを受けました"
60+
unreadCount={room.unreadMessages}
61+
/>
62+
</Box>
63+
);
64+
}
65+
if (room.matchingStatus === "myRequest") {
66+
return (
67+
<Box
68+
key={room.friendId}
69+
onClick={(e) => {
70+
e.stopPropagation();
71+
openRoom(room);
72+
}}
73+
>
74+
<HumanListItem
75+
key={room.friendId}
76+
id={room.friendId}
77+
name={room.name}
78+
pictureUrl={room.thumbnail}
79+
rollUpName={true}
80+
lastMessage={room.lastMsg?.content}
81+
statusMessage="リクエスト中 メッセージを送りましょう!"
82+
unreadCount={room.unreadMessages}
83+
/>
84+
</Box>
85+
);
86+
}
87+
return (
88+
<Box
89+
key={room.friendId}
90+
onClick={() => {
91+
openRoom(room);
92+
}}
93+
>
94+
<HumanListItem
95+
key={room.friendId}
96+
id={room.friendId}
97+
name={room.name}
98+
pictureUrl={room.thumbnail}
99+
rollUpName={true}
100+
lastMessage={room.lastMsg?.content}
101+
unreadCount={room.unreadMessages}
102+
/>
103+
</Box>
104+
);
105+
}
106+
return (
107+
<Typography key={room.roomId} variant="body2" sx={{ mb: 1 }}>
108+
グループチャット: {room.name}
109+
</Typography>
110+
);
111+
})}
112+
</List>
113+
) : (
114+
<RoomPage id={Number.parseInt(friendId)} />
115+
)}
116+
</>
117+
);
118+
}
119+
120+
export default RoomList;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import type { DMRoom, PersonalizedDMRoom } from "common/types";
33
import Link from "next/link";
44
import { useEffect, useState } from "react";
55
import * as chat from "~/api/chat/chat";
6-
import { RoomWindow } from "~/components/chat/RoomWindow";
76
import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress";
7+
import { RoomWindow } from "./RoomWindow";
88

9-
export default function Page({ params }: { params: { id: string } }) {
10-
const id = Number.parseInt(params.id);
9+
export default function RoomPage({ id }: { id: number }) {
1110
const [room, setRoom] = useState<(DMRoom & PersonalizedDMRoom) | null>(null);
1211
const [loading, setLoading] = useState(true);
1312

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { useMessages } from "~/api/chat/hooks";
88
import { API_ENDPOINT } from "~/api/internal/endpoints";
99
import request from "~/api/request";
1010
import { useMyID } from "~/api/user";
11-
import { handlers } from "../SSEProvider";
12-
import Dots from "../common/Dots";
11+
import Dots from "~/components/common/Dots";
12+
import { handlers } from "../../../components/SSEProvider";
1313
import { MessageInput } from "./MessageInput";
1414
import { RoomHeader } from "./RoomHeader";
1515

0 commit comments

Comments
 (0)