Skip to content

Commit d3442ad

Browse files
committed
style: 統一されたエディタ設定でフォーマット実行
1 parent 66439f7 commit d3442ad

115 files changed

Lines changed: 10856 additions & 10742 deletions

File tree

Some content is hidden

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

apps/api/src/index.ts

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,125 @@
1-
import { getCorsMiddleware } from "@/middleware/cors";
2-
import { errorHandler } from "@/middleware/error";
3-
import audioRoutes from "@/routes/audio";
4-
import { healthRoutes } from "@/routes/health";
5-
import pinsRoutes from "@/routes/pins";
6-
import { logger } from "@/utils/logger";
7-
import { Hono } from "hono";
8-
import { logger as honoLogger } from "hono/logger";
9-
import { requestId } from "hono/request-id";
10-
import { timing } from "hono/timing";
1+
import { getCorsMiddleware } from "@/middleware/cors"
2+
import { errorHandler } from "@/middleware/error"
3+
import audioRoutes from "@/routes/audio"
4+
import { healthRoutes } from "@/routes/health"
5+
import pinsRoutes from "@/routes/pins"
6+
import { logger } from "@/utils/logger"
7+
import { Hono } from "hono"
8+
import { logger as honoLogger } from "hono/logger"
9+
import { requestId } from "hono/request-id"
10+
import { timing } from "hono/timing"
1111

1212
/**
1313
* Cloudflare Workers環境変数の型定義
1414
*/
1515
export interface Env {
16-
// 環境変数
17-
ENVIRONMENT: "development" | "production";
18-
CORS_ORIGIN?: string;
16+
// 環境変数
17+
ENVIRONMENT: "development" | "production"
18+
CORS_ORIGIN?: string
1919

20-
// Supabase
21-
SUPABASE_URL: string;
22-
SUPABASE_ANON_KEY: string;
23-
SUPABASE_SERVICE_KEY: string;
20+
// Supabase
21+
SUPABASE_URL: string
22+
SUPABASE_ANON_KEY: string
23+
SUPABASE_SERVICE_KEY: string
2424

25-
// Python Audio Analyzer(YAMNet使用)
26-
PYTHON_AUDIO_ANALYZER_URL: string;
27-
PYTHON_AUDIO_ANALYZER_TIMEOUT: string;
25+
// Python Audio Analyzer(YAMNet使用)
26+
PYTHON_AUDIO_ANALYZER_URL: string
27+
PYTHON_AUDIO_ANALYZER_TIMEOUT: string
2828

29-
// KVネームスペース(将来使用)
30-
// CACHE: KVNamespace
29+
// KVネームスペース(将来使用)
30+
// CACHE: KVNamespace
3131

32-
// R2バケット(将来使用)
33-
// AUDIO_STORAGE: R2Bucket
32+
// R2バケット(将来使用)
33+
// AUDIO_STORAGE: R2Bucket
3434

35-
// Durable Objects(将来使用)
36-
// RATE_LIMITER: DurableObjectNamespace
35+
// Durable Objects(将来使用)
36+
// RATE_LIMITER: DurableObjectNamespace
3737
}
3838

3939
/**
4040
* Honoアプリケーションの初期化
4141
*/
42-
const app = new Hono<{ Bindings: Env }>();
42+
const app = new Hono<{ Bindings: Env }>()
4343

4444
// グローバルミドルウェア
45-
app.use("*", requestId());
46-
app.use("*", timing());
47-
app.use("*", honoLogger());
48-
app.use("*", errorHandler);
45+
app.use("*", requestId())
46+
app.use("*", timing())
47+
app.use("*", honoLogger())
48+
app.use("*", errorHandler)
4949

5050
// CORS設定(環境変数から取得)
5151
app.use("*", async (c, next) => {
52-
const corsMiddleware = getCorsMiddleware(c.env);
53-
return corsMiddleware(c, next);
54-
});
52+
const corsMiddleware = getCorsMiddleware(c.env)
53+
return corsMiddleware(c, next)
54+
})
5555

5656
// リクエストログ
5757
app.use("*", async (c, next) => {
58-
const start = Date.now();
59-
const method = c.req.method;
60-
const url = new URL(c.req.url);
61-
62-
logger.info("Request received", {
63-
requestId: c.get("requestId"),
64-
method,
65-
path: url.pathname,
66-
query: Object.fromEntries(url.searchParams),
67-
userAgent: c.req.header("user-agent"),
68-
});
69-
70-
await next();
71-
72-
const duration = Date.now() - start;
73-
const status = c.res.status;
74-
75-
logger.info("Request completed", {
76-
requestId: c.get("requestId"),
77-
method,
78-
path: url.pathname,
79-
status,
80-
duration,
81-
});
82-
});
58+
const start = Date.now()
59+
const method = c.req.method
60+
const url = new URL(c.req.url)
61+
62+
logger.info("Request received", {
63+
requestId: c.get("requestId"),
64+
method,
65+
path: url.pathname,
66+
query: Object.fromEntries(url.searchParams),
67+
userAgent: c.req.header("user-agent"),
68+
})
69+
70+
await next()
71+
72+
const duration = Date.now() - start
73+
const status = c.res.status
74+
75+
logger.info("Request completed", {
76+
requestId: c.get("requestId"),
77+
method,
78+
path: url.pathname,
79+
status,
80+
duration,
81+
})
82+
})
8383

8484
/**
8585
* ルートハンドラー
8686
*/
8787
app.get("/", (c) => {
88-
return c.json({
89-
success: true,
90-
data: {
91-
name: "Sonory API",
92-
version: "0.1.0",
93-
environment: c.env.ENVIRONMENT,
94-
timestamp: new Date().toISOString(),
95-
},
96-
});
97-
});
88+
return c.json({
89+
success: true,
90+
data: {
91+
name: "Sonory API",
92+
version: "0.1.0",
93+
environment: c.env.ENVIRONMENT,
94+
timestamp: new Date().toISOString(),
95+
},
96+
})
97+
})
9898

9999
// APIルート
100-
app.route("/api/health", healthRoutes);
101-
app.route("/api/audio", audioRoutes);
102-
app.route("/api/pins", pinsRoutes);
100+
app.route("/api/health", healthRoutes)
101+
app.route("/api/audio", audioRoutes)
102+
app.route("/api/pins", pinsRoutes)
103103

104104
// 404ハンドラー
105105
app.notFound((c) => {
106-
return c.json(
107-
{
108-
success: false,
109-
error: {
110-
code: "NOT_FOUND",
111-
message: "The requested resource was not found",
112-
timestamp: new Date().toISOString(),
113-
requestId: c.get("requestId"),
114-
},
115-
},
116-
404,
117-
);
118-
});
106+
return c.json(
107+
{
108+
success: false,
109+
error: {
110+
code: "NOT_FOUND",
111+
message: "The requested resource was not found",
112+
timestamp: new Date().toISOString(),
113+
requestId: c.get("requestId"),
114+
},
115+
},
116+
404,
117+
)
118+
})
119119

120120
/**
121121
* Cloudflare Workersエクスポート
122122
*/
123123
export default {
124-
fetch: app.fetch,
125-
};
124+
fetch: app.fetch,
125+
}

apps/api/src/middleware/cors.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import type { MiddlewareHandler } from "hono";
2-
import { cors } from "hono/cors";
1+
import type { MiddlewareHandler } from "hono"
2+
import { cors } from "hono/cors"
33

44
/**
55
* CORS設定を環境に応じて返す
66
* @param env - 環境変数
77
* @returns CORSミドルウェア
88
*/
99
export const getCorsMiddleware = (env: {
10-
CORS_ORIGIN?: string;
10+
CORS_ORIGIN?: string
1111
}): MiddlewareHandler => {
12-
const origin = env.CORS_ORIGIN || "http://localhost:3000";
12+
const origin = env.CORS_ORIGIN || "http://localhost:3000"
1313

14-
return cors({
15-
origin: origin.split(","), // カンマ区切りで複数のオリジンを許可
16-
allowHeaders: ["Content-Type", "Authorization", "X-Request-ID"],
17-
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
18-
exposeHeaders: ["X-Request-ID"],
19-
maxAge: 600,
20-
credentials: true,
21-
});
22-
};
14+
return cors({
15+
origin: origin.split(","), // カンマ区切りで複数のオリジンを許可
16+
allowHeaders: ["Content-Type", "Authorization", "X-Request-ID"],
17+
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
18+
exposeHeaders: ["X-Request-ID"],
19+
maxAge: 600,
20+
credentials: true,
21+
})
22+
}

0 commit comments

Comments
 (0)