Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*

# typescript
*.tsbuildinfo

# wrangler
wrangler.toml
66 changes: 66 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/routes/table.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import {
fetchPageById,
fetchTableData,
Expand Down Expand Up @@ -30,7 +31,7 @@ export const getTableData = async (

const tableArr: RowType[] =
table.result.reducerResults.collection_group_results.blockIds.map(
(id: string) => table.recordMap.block[id]
(id: string) => table.recordMap.block[id]?.value
);

const tableData = tableArr.filter(
Expand Down
10 changes: 5 additions & 5 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { HandlerRequest } from "../notion-api/types.js";

export const getNotionToken = (c: HandlerRequest) => {
return (
process.env.NOTION_TOKEN ||
(c.req.header("Authorization") || "").split("Bearer ")[1] ||
undefined
);
const fromContext = (c.env as { NOTION_TOKEN?: string } | undefined)?.NOTION_TOKEN;
const fromProcess =
typeof process !== "undefined" ? process.env?.NOTION_TOKEN : undefined;
const fromHeader = (c.req.header("Authorization") || "").split("Bearer ")[1];
return fromContext || fromProcess || fromHeader || undefined;
};