-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improve code]: lib/* 手動formatter・Linter対応 (#84)
* 🚨 astro/src/libにESLintのfixオプションを適用 * 🚨 Astroの環境変数をstring型とみなす記述を追加 * 🚨 nullish判定を明確化 * 💬 コメントの空白を半角に変更 * 🏷️ 変数の型情報を明記 * 🎨 astro/src/libにPrettierを適用 * ✏️ ファイル名getIdの綴りを修正 * ✏️ ファイル名変更に伴いimport文を修正 * 🏷️ Astro API用の型をZodで再定義 * 🦺 APIレスポンス取得箇所にバリデーションチェックを追加 * 🏷️ モジュール外で型の名前が重複しないよう変更 * 🩹 APIレスポンス処理時の型エラーに関する文言を修正 * 🏷️ API呼び出し箇所の型定義更新に伴い、エラー判定箇所を修正 * 🥅 getOgpMetaエラー時のステータス番号を定義 * ✏️ Zodオブジェクトの命名規則を統一 * 🥅 エラーレスポンスからhtmlを削除 * 🔥 使用されていないレスポンス型定義用のJSONを削除 * 🥅 エラー型判定の実装を改善 * 🥅 エラー型の判定を`"error" in val`形式で統一 * ⚰️ 使用されていない変数を削除 * ⚰️ 不要になった行を削除 * ➕ 依存関係にZodを追加 * 🥅 エラー型の判定ロジックを変更 & 型アサーション削除 * 🔥 不要になったインポート行を削除
- Loading branch information
Showing
17 changed files
with
314 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
export type ogpMetaData = { | ||
type: "meta" | ||
title: string, | ||
description: string, | ||
image: string, | ||
} | ||
import { z } from "zod" | ||
|
||
export const ZodOgpMetaData = z.object({ | ||
type: z.literal("meta"), | ||
title: z.string(), | ||
description: z.string(), | ||
image: z.string(), | ||
}) | ||
export type ogpMetaData = z.infer<typeof ZodOgpMetaData> | ||
|
||
// APIのエラーレスポンスを定義 | ||
export type errorResponse = { | ||
type: "error" | ||
error: string, | ||
message: string, | ||
status: number, | ||
} | ||
|
||
export type apiRequest = { | ||
type: "api" | ||
decodedUrl: string, | ||
language: string, | ||
} | ||
export const ZodErrorResponse = z.object({ | ||
type: z.literal("error"), | ||
error: z.string(), | ||
message: z.string(), | ||
status: z.number(), | ||
}) | ||
export type errorResponse = z.infer<typeof ZodErrorResponse> | ||
|
||
export const ZodApiRequest = z.object({ | ||
type: z.literal("api"), | ||
decodedUrl: z.string(), | ||
language: z.string(), | ||
}) | ||
export type apiRequest = z.infer<typeof ZodApiRequest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.