Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -2,7 +2,8 @@ import fetch from 'node-fetch';
|
|
| 2 |
import express from 'express';
|
| 3 |
import cors from 'cors';
|
| 4 |
import dotenv from 'dotenv';
|
| 5 |
-
import puppeteer from 'puppeteer'
|
|
|
|
| 6 |
|
| 7 |
dotenv.config();
|
| 8 |
|
|
@@ -103,13 +104,11 @@ class TokenManager {
|
|
| 103 |
|
| 104 |
async updateTokens(response, isWaf = false) {
|
| 105 |
if (isWaf) {
|
| 106 |
-
console.log("更新waf");
|
| 107 |
var wafToken = await Utils.extractWaf();
|
| 108 |
if (wafToken) {
|
| 109 |
Tokens[currentIndex].aws_waf_token = wafToken;
|
| 110 |
await this.updateCacheTokens();
|
| 111 |
this.updateRedisTokens();
|
| 112 |
-
return;
|
| 113 |
} else {
|
| 114 |
currentIndex = (currentIndex + 1) % Tokens.length;
|
| 115 |
await this.updateCacheTokens();
|
|
@@ -228,7 +227,7 @@ async function initializeService() {
|
|
| 228 |
console.log('服务初始化中...');
|
| 229 |
tokenManager = new TokenManager();
|
| 230 |
redisClient = new RedisClient();
|
| 231 |
-
|
| 232 |
let index = 0;
|
| 233 |
while (true) {
|
| 234 |
console.log(index, '开始检测是否有缓存');
|
|
@@ -587,7 +586,7 @@ app.post('/hf/v1/chat/completions', async (req, res) => {
|
|
| 587 |
|
| 588 |
|
| 589 |
app.use((req, res) => {
|
| 590 |
-
res.status(404).
|
| 591 |
});
|
| 592 |
|
| 593 |
// 启动服务器
|
|
|
|
| 2 |
import express from 'express';
|
| 3 |
import cors from 'cors';
|
| 4 |
import dotenv from 'dotenv';
|
| 5 |
+
import puppeteer from 'puppeteer-extra'
|
| 6 |
+
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
| 7 |
|
| 8 |
dotenv.config();
|
| 9 |
|
|
|
|
| 104 |
|
| 105 |
async updateTokens(response, isWaf = false) {
|
| 106 |
if (isWaf) {
|
|
|
|
| 107 |
var wafToken = await Utils.extractWaf();
|
| 108 |
if (wafToken) {
|
| 109 |
Tokens[currentIndex].aws_waf_token = wafToken;
|
| 110 |
await this.updateCacheTokens();
|
| 111 |
this.updateRedisTokens();
|
|
|
|
| 112 |
} else {
|
| 113 |
currentIndex = (currentIndex + 1) % Tokens.length;
|
| 114 |
await this.updateCacheTokens();
|
|
|
|
| 227 |
console.log('服务初始化中...');
|
| 228 |
tokenManager = new TokenManager();
|
| 229 |
redisClient = new RedisClient();
|
| 230 |
+
puppeteer.use(StealthPlugin())
|
| 231 |
let index = 0;
|
| 232 |
while (true) {
|
| 233 |
console.log(index, '开始检测是否有缓存');
|
|
|
|
| 586 |
|
| 587 |
|
| 588 |
app.use((req, res) => {
|
| 589 |
+
res.status(404).send("API服务运行正常,,请使用正确请求路径");
|
| 590 |
});
|
| 591 |
|
| 592 |
// 启动服务器
|