Skip to content

Commit 5e3d30f

Browse files
authored
ディレクトリ構造とスクリプトの修正と Storybook の追加 (#66)
差分が大きくなりすぎたので、ブランチ名になってる tweak ui は別で。
1 parent 2a8ccee commit 5e3d30f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+874
-484
lines changed

biome.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.1.1/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

bun.lock

Lines changed: 136 additions & 115 deletions
Large diffs are not rendered by default.

docs/developer_readme.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ bun install --frozen-lockfile
99

1010
## 開発
1111

12-
開発モードを実行するには、以下のコマンドを実行してください。
1312

1413
```bash
14+
# 開発モードを実行するには、以下のコマンドを実行してください。
15+
# localhost:5173 に Vite サーバーが立ち上がるので、そこで確認してください。
1516
bun dev
17+
18+
# Storybookの使用
19+
# localhost:6006にStorybookが立ち上がるので、そこでUIを確認してください。
20+
bun run storybook
1621
```
1722

1823
コードをプッシュする前に、コード品質をチェックするために以下のコマンドを実行してください。
@@ -60,9 +65,3 @@ Userのデータは`User`クラスを使用して扱います。Userのデータ
6065
}
6166
}
6267
```
63-
64-
## Storybookの使用
65-
```bash
66-
bun run storybook
67-
```
68-
- localhost:6006にStorybookが立ち上がるので、そこでUIを確認してください。

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
"scripts": {
99
"dev": "bun --filter=@packages/{web,server} dev",
1010
"dev:mock": "bun --filter=@packages/{web,server} dev:mock",
11+
"storybook": "concurrently 'cd packages/server; bun dev' 'cd packages/web; bun run storybook'",
1112
"build": "cd packages/web && bun run build",
1213
"check": "bunx biome check .",
1314
"fix": "bunx biome check . --fix"
1415
},
1516
"devDependencies": {
16-
"@biomejs/biome": "^2.1.1"
17+
"@biomejs/biome": "^2.1.1",
18+
"concurrently": "^9.2.0"
1719
}
1820
}

packages/models/models.ts

Lines changed: 89 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,93 @@
11
import { t } from "elysia";
22

3-
export type CreateUser = typeof CreateUser.static;
4-
export const CreateUser = t.Object({
5-
name: t.String({
6-
minLength: 1,
7-
maxLength: 255,
8-
}),
9-
});
3+
// TODO: Elysia のスキーマにする
4+
// サンプル変換:
105

11-
export type User = typeof User.static;
12-
export const User = t.Object({
13-
id: t.String({ format: "uuid" }),
14-
...CreateUser.properties,
6+
export type Stream = typeof Stream.static;
7+
export const Stream = t.Enum({
8+
s1: "s1",
9+
s2: "s2",
10+
s3: "s3",
11+
l1: "l1",
12+
l2: "l2",
13+
l3: "l3",
1514
});
15+
16+
export type User = {
17+
stream: Stream | undefined;
18+
grade: number | undefined;
19+
classNumber: number | undefined;
20+
};
21+
22+
export type ClassDataType = {
23+
code: string;
24+
type: string;
25+
category: string;
26+
semester: string;
27+
dayPeriod: DayPeriod[] | "集中";
28+
classroom: string;
29+
titleJp: string;
30+
lecturer: string;
31+
titleEn: string;
32+
lecturerEn: string;
33+
ccCode: string;
34+
credits: number;
35+
detail: string;
36+
schedule: string;
37+
methods: string;
38+
evaluation: string;
39+
notes: string;
40+
class: string;
41+
guidance: string;
42+
guidanceDate: string;
43+
guidancePeriod: string;
44+
time: number;
45+
timeCompensation: string;
46+
targetClass: string[][];
47+
importance: string[][];
48+
shortenedCategory: string;
49+
shortenedEvaluation: string;
50+
shortenedClassroom: string;
51+
};
52+
53+
export type Day = "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
54+
55+
export type DayPeriod = {
56+
day: Day;
57+
period: 1 | 2 | 3 | 4 | 5 | 6;
58+
};
59+
60+
export const dayMapping: { [key in Day]: string } = {
61+
mon: "月",
62+
tue: "火",
63+
wed: "水",
64+
thu: "木",
65+
fri: "金",
66+
sat: "土",
67+
};
68+
69+
/**
70+
* セメスターを表現する型
71+
*/
72+
export type Semester = "S" | "S1" | "S2" | "A" | "A1" | "A2";
73+
74+
/**
75+
* 評価方法を表現する型
76+
*/
77+
export type Evaluation = "試験" | "レポート" | "出席" | "平常";
78+
79+
/**
80+
* セメスターを表現する型
81+
*/
82+
export type ClassType =
83+
| "基礎"
84+
| "要求"
85+
| "主題"
86+
| "展開"
87+
| "L"
88+
| "A"
89+
| "B"
90+
| "C"
91+
| "D"
92+
| "E"
93+
| "F";

packages/server/app.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
11
import { cors } from "@elysiajs/cors";
22
import { Elysia } from "elysia";
3-
import { auth } from "./lib/auth.ts";
4-
import { usersRouter } from "./router/users.sample.ts";
5-
6-
const betterAuth = new Elysia({ name: "better-auth" })
7-
.mount(auth.handler)
8-
.macro({
9-
auth: {
10-
async resolve({ status, request: { headers } }) {
11-
const session = await auth.api.getSession({
12-
headers,
13-
});
14-
if (!session) return status(401);
15-
16-
return {
17-
user: session.user,
18-
session: session.session,
19-
};
20-
},
21-
},
22-
});
3+
import { betterAuth } from "./lib/auth.ts";
234

245
export const app = new Elysia({
256
prefix: "/api",
267
})
278
.use(betterAuth)
28-
.use(cors())
29-
.group("/users", (app) => app.use(usersRouter));
9+
.use(cors());
3010

3111
export type App = typeof app;

packages/server/lib/auth.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { betterAuth } from "better-auth";
22
import { drizzleAdapter } from "better-auth/adapters/drizzle";
3+
import Elysia from "elysia";
34
import { db } from "../db/index.ts";
45
import * as schema from "../db/schema.ts";
56

@@ -16,3 +17,22 @@ export const auth = betterAuth({
1617
},
1718
trustedOrigins: [process.env.PUBLIC_WEB_URL ?? "http://localhost:3000"],
1819
});
20+
21+
const betterAuthMacro = new Elysia({ name: "better-auth" })
22+
.mount(auth.handler)
23+
.macro({
24+
auth: {
25+
async resolve({ status, request: { headers } }) {
26+
const session = await auth.api.getSession({
27+
headers,
28+
});
29+
if (!session) return status(401);
30+
31+
return {
32+
user: session.user,
33+
session: session.session,
34+
};
35+
},
36+
},
37+
});
38+
export { betterAuthMacro as betterAuth };

packages/server/router/users.sample.ts

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

packages/web/.storybook/preview.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { Preview } from "@storybook/react";
2+
import "../src/app.css";
3+
import { ThemeContext, useThemeProvider } from "@/services/theme/index.ts";
4+
5+
const preview: Preview = {
6+
parameters: {
7+
controls: {
8+
matchers: {
9+
color: /(background|color)$/i,
10+
date: /Date$/i,
11+
},
12+
},
13+
},
14+
};
15+
16+
export default preview;
17+
18+
export const decorators = [
19+
(Story: () => React.ReactNode) => {
20+
const provider = useThemeProvider();
21+
return (
22+
<ThemeContext.Provider value={provider}>
23+
<Story />
24+
</ThemeContext.Provider>
25+
);
26+
},
27+
];

0 commit comments

Comments
 (0)