diff --git a/src/api/notion.ts b/src/api/notion.ts index b88e5aa..f57a897 100644 --- a/src/api/notion.ts +++ b/src/api/notion.ts @@ -1,6 +1,5 @@ import { JSONData, - BlockMapType, NotionUserType, LoadPageChunkData, CollectionData, diff --git a/src/api/types.ts b/src/api/types.ts index 1dadea5..11ead0f 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -179,7 +179,7 @@ export interface NotionSearchResultsType { total: number; } -export interface HandlerRequest = { +export interface HandlerRequest { params: Params; searchParams: URLSearchParams; request: Request; diff --git a/src/index.ts b/src/index.ts index a7e3555..0f9a31a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import {} from "@cloudflare/workers-types"; -import { Router, Method, Params } from "tiny-request-router"; +import { Router, Method } from "tiny-request-router"; import { pageRoute } from "./routes/page"; import { tableRoute } from "./routes/table"; diff --git a/src/routes/page.ts b/src/routes/page.ts index 7c1d6cc..eb2622d 100644 --- a/src/routes/page.ts +++ b/src/routes/page.ts @@ -1,4 +1,3 @@ -import { Params } from "tiny-request-router"; import { fetchPageById, fetchBlocks } from "../api/notion"; import { parsePageId } from "../api/utils"; import { createResponse } from "../response"; @@ -7,7 +6,7 @@ import { CollectionType, BlockType, HandlerRequest } from "../api/types"; export async function pageRoute(req: HandlerRequest) { const pageId = parsePageId(req.params.pageId); - const page = await fetchPageById(pageId, req.notionToken); + const page = await fetchPageById(pageId!, req.notionToken); const baseBlocks = page.recordMap.block; diff --git a/src/routes/search.ts b/src/routes/search.ts index 1e9655a..cf76a1b 100644 --- a/src/routes/search.ts +++ b/src/routes/search.ts @@ -4,9 +4,9 @@ import { HandlerRequest } from "../api/types"; import { parsePageId } from "../api/utils"; export async function searchRoute(req: HandlerRequest) { - const ancestorId = parsePageId(req.searchParams.get("ancestorId")); + const ancestorId = parsePageId(req.searchParams.get("ancestorId") || ""); const query = req.searchParams.get("query") || ""; - const limit = req.searchParams.get("limit") || 20; + const limit = Number(req.searchParams.get("limit") || 20); if (!ancestorId) { return createResponse( diff --git a/src/routes/table.ts b/src/routes/table.ts index 59d7b02..c0953bb 100644 --- a/src/routes/table.ts +++ b/src/routes/table.ts @@ -1,4 +1,3 @@ -import { Params } from "tiny-request-router"; import { fetchPageById, fetchTableData, fetchNotionUsers } from "../api/notion"; import { parsePageId, getNotionValue } from "../api/utils"; import { @@ -58,7 +57,7 @@ export const getTableData = async ( export async function tableRoute(req: HandlerRequest) { const pageId = parsePageId(req.params.pageId); - const page = await fetchPageById(pageId, req.notionToken); + const page = await fetchPageById(pageId!, req.notionToken); if (!page.recordMap.collection) return createResponse( diff --git a/src/routes/user.ts b/src/routes/user.ts index a847457..c80f014 100644 --- a/src/routes/user.ts +++ b/src/routes/user.ts @@ -1,4 +1,3 @@ -import { Params } from "tiny-request-router"; import { fetchNotionUsers } from "../api/notion"; import { HandlerRequest } from "../api/types"; import { createResponse } from "../response";