Upload 17 files
Browse files- package.json +37 -37
- src/lightweight-client-express.js +7 -0
- src/lightweight-client.js +4 -11
package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "notion2api-nodejs",
|
| 3 |
-
"version": "1.0.0",
|
| 4 |
-
"description": "Notion API client with lightweight browser-free option",
|
| 5 |
-
"main": "src/lightweight-client-express.js",
|
| 6 |
-
"type": "module",
|
| 7 |
-
"bin": {
|
| 8 |
-
"notion-cookie": "src/cookie-cli.js"
|
| 9 |
-
},
|
| 10 |
-
"scripts": {
|
| 11 |
-
"start": "node src/lightweight-client-express.js",
|
| 12 |
-
"dev": "nodemon src/lightweight-client-express.js",
|
| 13 |
-
"original": "node src/index.js",
|
| 14 |
-
"cookie": "node src/cookie-cli.js"
|
| 15 |
-
},
|
| 16 |
-
"keywords": [
|
| 17 |
-
"notion",
|
| 18 |
-
"openai",
|
| 19 |
-
"api",
|
| 20 |
-
"bridge"
|
| 21 |
-
],
|
| 22 |
-
"author": "",
|
| 23 |
-
"license": "MIT",
|
| 24 |
-
"dependencies": {
|
| 25 |
-
"axios": "^1.9.0",
|
| 26 |
-
"chalk": "^4.1.2",
|
| 27 |
-
"dotenv": "^16.3.1",
|
| 28 |
-
"express": "^4.18.2",
|
| 29 |
-
"https-proxy-agent": "^7.0.2",
|
| 30 |
-
"jsdom": "^22.1.0",
|
| 31 |
-
"node-fetch": "^3.3.2",
|
| 32 |
-
"playwright": "^1.40.1"
|
| 33 |
-
},
|
| 34 |
-
"devDependencies": {
|
| 35 |
-
"nodemon": "^3.0.2"
|
| 36 |
-
}
|
| 37 |
-
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "notion2api-nodejs",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "Notion API client with lightweight browser-free option",
|
| 5 |
+
"main": "src/lightweight-client-express.js",
|
| 6 |
+
"type": "module",
|
| 7 |
+
"bin": {
|
| 8 |
+
"notion-cookie": "src/cookie-cli.js"
|
| 9 |
+
},
|
| 10 |
+
"scripts": {
|
| 11 |
+
"start": "node src/lightweight-client-express.js",
|
| 12 |
+
"dev": "nodemon src/lightweight-client-express.js",
|
| 13 |
+
"original": "node src/index.js",
|
| 14 |
+
"cookie": "node src/cookie-cli.js"
|
| 15 |
+
},
|
| 16 |
+
"keywords": [
|
| 17 |
+
"notion",
|
| 18 |
+
"openai",
|
| 19 |
+
"api",
|
| 20 |
+
"bridge"
|
| 21 |
+
],
|
| 22 |
+
"author": "",
|
| 23 |
+
"license": "MIT",
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"axios": "^1.9.0",
|
| 26 |
+
"chalk": "^4.1.2",
|
| 27 |
+
"dotenv": "^16.3.1",
|
| 28 |
+
"express": "^4.18.2",
|
| 29 |
+
"https-proxy-agent": "^7.0.2",
|
| 30 |
+
"jsdom": "^22.1.0",
|
| 31 |
+
"node-fetch": "^3.3.2",
|
| 32 |
+
"playwright": "^1.40.1"
|
| 33 |
+
},
|
| 34 |
+
"devDependencies": {
|
| 35 |
+
"nodemon": "^3.0.2"
|
| 36 |
+
}
|
| 37 |
+
}
|
src/lightweight-client-express.js
CHANGED
|
@@ -23,6 +23,13 @@ const __dirname = dirname(__filename);
|
|
| 23 |
// 加载环境变量
|
| 24 |
dotenv.config({ path: join(dirname(__dirname), '.env') });
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
// 日志配置
|
| 27 |
const logger = {
|
| 28 |
info: (message) => console.log(chalk.blue(`[info] ${message}`)),
|
|
|
|
| 23 |
// 加载环境变量
|
| 24 |
dotenv.config({ path: join(dirname(__dirname), '.env') });
|
| 25 |
|
| 26 |
+
// 在启动时打印NOTION_COOKIE环境变量
|
| 27 |
+
if (process.env.NOTION_COOKIE) {
|
| 28 |
+
console.log(chalk.yellow(`[Startup] NOTION_COOKIE value: ${process.env.NOTION_COOKIE}`));
|
| 29 |
+
} else {
|
| 30 |
+
console.log(chalk.yellow(`[Startup] NOTION_COOKIE environment variable is not set.`));
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
// 日志配置
|
| 34 |
const logger = {
|
| 35 |
info: (message) => console.log(chalk.blue(`[info] ${message}`)),
|
src/lightweight-client.js
CHANGED
|
@@ -360,21 +360,14 @@ async function fetchNotionResponse(chunkQueue, notionRequestBody, headers, notio
|
|
| 360 |
let response = null;
|
| 361 |
// 发送请求
|
| 362 |
if (ENABLE_PROXY_SERVER){
|
| 363 |
-
|
| 364 |
-
response = await fetch(`http://127.0.0.1:${proxyPort}/proxy`, {
|
| 365 |
method: 'POST',
|
| 366 |
-
headers: {
|
| 367 |
-
'Content-Type': 'application/json'
|
| 368 |
-
},
|
| 369 |
body: JSON.stringify({
|
| 370 |
method: 'POST',
|
| 371 |
url: notionApiUrl,
|
| 372 |
-
headers:
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
},
|
| 376 |
-
body: notionRequestBody,
|
| 377 |
-
stream: true
|
| 378 |
}),
|
| 379 |
});
|
| 380 |
}else{
|
|
|
|
| 360 |
let response = null;
|
| 361 |
// 发送请求
|
| 362 |
if (ENABLE_PROXY_SERVER){
|
| 363 |
+
response = await fetch('http://127.0.0.1:10655/proxy', {
|
|
|
|
| 364 |
method: 'POST',
|
|
|
|
|
|
|
|
|
|
| 365 |
body: JSON.stringify({
|
| 366 |
method: 'POST',
|
| 367 |
url: notionApiUrl,
|
| 368 |
+
headers: fetchOptions.headers,
|
| 369 |
+
body: fetchOptions.body,
|
| 370 |
+
stream:true
|
|
|
|
|
|
|
|
|
|
| 371 |
}),
|
| 372 |
});
|
| 373 |
}else{
|