Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"globals": "^15.15.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.24.1",
"vite": "^6.2.3",
"vite": "^6.3.5",
},
},
"common": {
Expand Down Expand Up @@ -944,7 +944,7 @@

"vary": ["[email protected]", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],

"vite": ["[email protected].3", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", "picomatch": "^4.0.2", "postcss": "^8.5.3", "rollup": "^4.34.9", "tinyglobby": "^0.2.13" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-5nXH+QsELbFKhsEfWLkHrvgRpTdGJzqOZ+utSdmPTvwHmvU6ITTm3xx+mRusihkcI8GeC7lCDyn3kDtiki9scw=="],
"vite": ["[email protected].5", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", "picomatch": "^4.0.2", "postcss": "^8.5.3", "rollup": "^4.34.9", "tinyglobby": "^0.2.13" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ=="],

"which": ["[email protected]", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions client/.env.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_API_ENDPOINT=https://api.itsuhima-staging.utcode.net
VITE_FRONTEND_ORIGIN=https://itsuhima-staging.utcode.net
2 changes: 2 additions & 0 deletions client/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_API_ENDPOINT=https://api.itsuhima.utcode.net
VITE_FRONTEND_ORIGIN=https://itsuhima.utcode.net
5 changes: 5 additions & 0 deletions client/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [[ "$CF_PAGES_BRANCH" == "main" ]]; then
npm run build
else
npm run build:preview
fi
31 changes: 12 additions & 19 deletions client/functions/[[path]].ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="@cloudflare/workers-types" />

interface Env {
VITE_API_ENDPOINT: string;
API_ENDPOINT: string;
}

interface ProjectData {
Expand Down Expand Up @@ -47,16 +47,17 @@ class OGDescriptionRewriter {
}
}

// 日付を YYYY/MM/DD 形式にフォーマット
// 日付を YYYY/MM/DD 形式にフォーマット(日本時間)
function formatDate(dateString: string): string {
const date = new Date(dateString);
return `${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, "0")}/${String(date.getDate()).padStart(2, "0")}`;
}

// 時刻を HH:MM 形式にフォーマット
function formatTime(dateString: string): string {
const date = new Date(dateString);
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
return new Intl.DateTimeFormat("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
timeZone: "Asia/Tokyo",
})
.format(date)
.replace(/-/g, "/");
}

// プロジェクト情報を取得
Expand Down Expand Up @@ -124,7 +125,7 @@ export async function onRequest(context: EventContext<Env, any, any>): Promise<R
}

// プロジェクト情報を取得
const projectData = await fetchProjectData(eventId, env.VITE_API_ENDPOINT);
const projectData = await fetchProjectData(eventId, env.API_ENDPOINT);

if (!projectData) {
return response;
Expand All @@ -138,15 +139,7 @@ export async function onRequest(context: EventContext<Env, any, any>): Promise<R
const endDate = formatDate(projectData.endDate);
const dateRange = startDate === endDate ? startDate : `${startDate} - ${endDate}`;

let timeRange = "";
if (projectData.allowedRanges && projectData.allowedRanges.length > 0) {
const range = projectData.allowedRanges[0];
const startTime = formatTime(range.startTime);
const endTime = formatTime(range.endTime);
timeRange = `${startTime} - ${endTime}`;
}

const ogDescription = timeRange ? `日程: ${dateRange} | 時間: ${timeRange}` : `日程: ${dateRange}`;
const ogDescription = `日程範囲: ${dateRange}`;

return new HTMLRewriter()
.on('meta[property="og:title"]', new OGTitleRewriter(ogTitle))
Expand Down
5 changes: 4 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"type": "module",
"scripts": {
"dev": "vite",
"build:local:watch": "tsc -b && vite build --watch --mode dev",
"build:local": "tsc -b && vite build --mode dev",
"build:preview": "tsc -b && vite build --mode preview",
"build": "tsc -b && vite build",
"lint": "eslint .",
"format": "prettier . --check",
Expand Down Expand Up @@ -42,6 +45,6 @@
"globals": "^15.15.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.24.1",
"vite": "^6.2.3"
"vite": "^6.3.5"
}
}
6 changes: 3 additions & 3 deletions client/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ compatibility_date = "2024-12-01"
pages_build_output_dir = "./dist"

[env.production.vars]
VITE_API_ENDPOINT = "https://api.itsuhima.utcode.net"
API_ENDPOINT = "https://api.itsuhima.utcode.net"

[env.preview.vars]
VITE_API_ENDPOINT = ""
API_ENDPOINT = "https://api.itsuhima-staging.utcode.net"

[vars]
VITE_API_ENDPOINT = "http://localhost:3000"
API_ENDPOINT = "http://localhost:3000"
15 changes: 15 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
postgres:
image: postgres:16-alpine
container_name: itsuhima-postgres
environment:
POSTGRES_DB: itsuhima_dev
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

volumes:
postgres_data:
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"version": "1.0.0",
"workspaces": ["client", "server", "common"],
"scripts": {
"dev": "concurrently --kill-others 'npm run dev:server' 'npm run dev:client'",
"watch:client": "cd client && npm run build:local:watch",
"dev:functions": "cd client && npx wrangler pages dev dist --compatibility-date=2024-12-01",
"dev:server": "cd server && npm run dev",
"dev:client": "cd client && npm run dev",
"dev:db": "docker compose up",
"check": "npx biome check",
"fix": "npx @biomejs/biome check --fix --unsafe",
"fix:safe": "npx @biomejs/biome check --fix"
Expand Down
4 changes: 2 additions & 2 deletions server/.env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DATABASE_URL=
DATABASE_URL=postgresql://postgres:password@localhost:5432/itsuhima_dev
CORS_ALLOW_ORIGINS=http://localhost:5173
DOMAIN=localhost
NODE_ENV=dev # dev or prod
COOKIE_SECRET=
COOKIE_SECRET=your-random-secret-key-for-development