Skip to content

Commit bd0bac9

Browse files
committed
build(cloudfare): config cloudfare wk
1 parent 10761cc commit bd0bac9

3 files changed

Lines changed: 74 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ yarn-error.log*
3333

3434
# typescript
3535
*.tsbuildinfo
36+
37+
# wrangler
38+
wrangler.toml

package-lock.json

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { HandlerRequest } from "../notion-api/types.js";
22

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

0 commit comments

Comments
 (0)