mirror of
https://github.com/zhigang1992/notion-api-worker.git
synced 2026-01-12 17:32:42 +08:00
Typing fixes from #8
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
JSONData,
|
||||
BlockMapType,
|
||||
NotionUserType,
|
||||
LoadPageChunkData,
|
||||
CollectionData,
|
||||
|
||||
@@ -179,7 +179,7 @@ export interface NotionSearchResultsType {
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface HandlerRequest = {
|
||||
export interface HandlerRequest {
|
||||
params: Params;
|
||||
searchParams: URLSearchParams;
|
||||
request: Request;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Params } from "tiny-request-router";
|
||||
import { fetchNotionUsers } from "../api/notion";
|
||||
import { HandlerRequest } from "../api/types";
|
||||
import { createResponse } from "../response";
|
||||
|
||||
Reference in New Issue
Block a user