diff --git a/astro/src/lib/pagedbAPI/createPage.ts b/astro/src/lib/pagedbAPI/createPage.ts index 450065e..1e1c8e9 100644 --- a/astro/src/lib/pagedbAPI/createPage.ts +++ b/astro/src/lib/pagedbAPI/createPage.ts @@ -6,7 +6,7 @@ const endpoint_url = import.meta.env.PUBLIC_CREATEPAGES_ENDPOINT as string const PageCreationOutputZod = z.object({ uri: z.string(), }) -type output = z.infer +export type pageCreationOutput = z.infer /** * pageDBへページを追加 @@ -21,7 +21,7 @@ export const api = async ({ }: { uri: string accessJwt: string -}): Promise => { +}): Promise => { return fetch(endpoint_url, { method: "POST", headers: { @@ -43,7 +43,7 @@ export const api = async ({ e.name = "Unexpected Response Type@createPage::api" throw e } - const apiResult: output = responseParsed.data + const apiResult: pageCreationOutput = responseParsed.data return apiResult }) .catch((e: Error) => { diff --git a/astro/src/lib/pagedbAPI/deletePage.ts b/astro/src/lib/pagedbAPI/deletePage.ts index 0998a43..e632487 100644 --- a/astro/src/lib/pagedbAPI/deletePage.ts +++ b/astro/src/lib/pagedbAPI/deletePage.ts @@ -6,7 +6,7 @@ const endpoint_url = import.meta.env.PUBLIC_DELETEPAGE_ENDPOINT as string const PageDeletionOutputZod = z.object({ result: z.string(), }) -type output = z.infer +export type pageDeletionOutput = z.infer /** * pageDBからデータを削除 @@ -24,7 +24,7 @@ export const api = async ({ id: string did: string accessJwt: string -}): Promise => { +}): Promise => { return fetch(endpoint_url, { method: "POST", headers: { @@ -48,7 +48,7 @@ export const api = async ({ e.name = "Unexpected Response Type@deletePage::api" throw e } - const apiResult: output = responseParsed.data + const apiResult: pageDeletionOutput = responseParsed.data return apiResult }) .catch((e: Error) => { diff --git a/astro/src/lib/pagedbAPI/getIds.ts b/astro/src/lib/pagedbAPI/getIds.ts index 5d0dec8..6a879e1 100644 --- a/astro/src/lib/pagedbAPI/getIds.ts +++ b/astro/src/lib/pagedbAPI/getIds.ts @@ -6,7 +6,7 @@ const object = "user" const IdsFetchOutputZod = z.object({ ids: z.array(z.string()), }) -type output = { +export type idsFetchOutput = { ids: Array } @@ -14,7 +14,7 @@ export const api = async ({ handle, }: { handle: string -}): Promise => { +}): Promise => { const url = new URL(object + "/" + encodeURIComponent(handle), endpoint_url) return fetch(url, { method: "GET", @@ -26,12 +26,14 @@ export const api = async ({ const responseParsed = IdsFetchOutputZod.safeParse(response.json()) if (!responseParsed.success) { - const e: Error = new Error("Unexpected Response Type@getIds::api") + const e: Error = new Error( + "Unexpected Response Type@getIds::api", + ) e.name = "Unexpected Response Type@getIds::api" throw e } - const apiResult: output = responseParsed.data + const apiResult: idsFetchOutput = responseParsed.data return apiResult }) .catch((e: Error) => { diff --git a/astro/src/lib/pagedbAPI/getPage.ts b/astro/src/lib/pagedbAPI/getPage.ts index 6d5e57b..b6bb513 100644 --- a/astro/src/lib/pagedbAPI/getPage.ts +++ b/astro/src/lib/pagedbAPI/getPage.ts @@ -12,13 +12,13 @@ export const PageFetchOutputZod = z.object({ }), ), }) -export type output = z.infer +export type pageFetchOutput = z.infer export const api = async ({ id, }: { id: string -}): Promise => { +}): Promise => { const url = new URL(object + "/" + encodeURIComponent(id), endpoint_url) return fetch(url, { method: "GET", @@ -27,17 +27,17 @@ export const api = async ({ }, }) .then(response => { - const responseParsed = PageFetchOutputZod.safeParse( - response.json(), - ) + const responseParsed = PageFetchOutputZod.safeParse(response.json()) if (!responseParsed.success) { - const e: Error = new Error("Unexpected Response Type@getPages::api") + const e: Error = new Error( + "Unexpected Response Type@getPages::api", + ) e.name = "Unexpected Response Type@getPages::api" throw e } - const apiResult: output = responseParsed.data + const apiResult: pageFetchOutput = responseParsed.data return apiResult }) .catch((e: Error) => {