Skip to content

Commit 4caf718

Browse files
authored
Support edge runtime such as cloudflare workers (#81)
* Support edge runtime such as cloudflare workers * fix * fix incomplete URL substring sanitization * add playwright
1 parent 5c9047c commit 4caf718

14 files changed

+29408
-8152
lines changed

lib/notion-client/browser.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './notion-api';
2+
export * from './types';

lib/notion-client/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './notion-api-universal';
2+
export * from './types';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import test from 'ava';
2+
3+
import { NotionAPI } from './notion-api-universal';
4+
5+
const pageIdFixturesSuccess = [
6+
'067dd719-a912-471e-a9a3-ac10710e7fdf',
7+
'067dd719a912471ea9a3ac10710e7fdf',
8+
'https://www.notion.so/saasifysh/Embeds-5d4e290ca4604d8fb809af806a6c1749',
9+
'https://www.notion.so/saasifysh/File-Uploads-34d650c65da34f888335dbd3ddd141dc',
10+
'Color-Rainbow-54bf56611797480c951e5c1f96cb06f2',
11+
'e68c18a461904eb5a2ddc3748e76b893',
12+
'https://www.notion.so/saasifysh/Saasify-Key-Takeaways-689a8abc1afa4699905aa2f2e585e208',
13+
'https://www.notion.so/saasifysh/TransitiveBullsh-it-78fc5a4b88d74b0e824e29407e9f1ec1',
14+
'https://www.notion.so/saasifysh/About-8d0062776d0c4afca96eb1ace93a7538',
15+
'https://www.notion.so/potionsite/newest-board-a899b98b7cdc424585e5ddebbdae60cc',
16+
17+
// collections stress test
18+
// NOTE: removing because of sporadic timeouts
19+
// 'nba-3f92ae505636427c897634a15b9f2892'
20+
];
21+
22+
const pageIdFixturesFailure = [
23+
'bdecdf150d0e40cb9f3412be132335d4', // private page
24+
'foo', // invalid page id
25+
];
26+
27+
for (const pageId of pageIdFixturesSuccess) {
28+
test(`NotionAPI.getPage success ${pageId}`, async (t) => {
29+
t.timeout(60000); // one minute timeout
30+
31+
const api = new NotionAPI();
32+
const page = await api.getPage(pageId);
33+
34+
t.truthy(page);
35+
t.truthy(page.block);
36+
});
37+
}
38+
39+
for (const pageId of pageIdFixturesFailure) {
40+
test(`NotionAPI.getPage failure ${pageId}`, async (t) => {
41+
const api = new NotionAPI();
42+
await t.throwsAsync(() => api.getPage(pageId));
43+
});
44+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This adds Node.js support for `fetch` and `abort-controller`
2+
import 'ky-universal';
3+
4+
export { NotionAPI } from './notion-api';

0 commit comments

Comments
 (0)