Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick:

Nicolas04942bb9dea1
diff --git a/apps/api/fly.toml b/apps/api/fly.toml
index e248e59b3..94108e5fe 100644
--- a/apps/api/fly.toml
+++ b/apps/api/fly.toml
@@ -24,8 +24,8 @@ kill_timeout = '30s'
[http_service.concurrency]
type = "requests"
- hard_limit = 100
- soft_limit = 50
+ hard_limit = 200
+ soft_limit = 75
[[http_service.checks]]
grace_period = "20s"
diff --git a/apps/api/package.json b/apps/api/package.json
index da1b2b33f..153ac8413 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -63,6 +63,7 @@
"axios": "^1.3.4",
"bottleneck": "^2.19.5",
"bull": "^4.15.0",
+ "cacheable-lookup": "^6.1.0",
"cheerio": "^1.0.0-rc.12",
"cohere": "^1.1.1",
"cors": "^2.8.5",
diff --git a/apps/api/pnpm-lock.yaml b/apps/api/pnpm-lock.yaml
index 02d8363ba..9c8dbbc93 100644
--- a/apps/api/pnpm-lock.yaml
+++ b/apps/api/pnpm-lock.yaml
@@ -59,6 +59,9 @@ importers:
bull:
specifier: ^4.15.0
version: 4.15.0
+ cacheable-lookup:
+ specifier: ^6.1.0
+ version: 6.1.0
cheerio:
specifier: ^1.0.0-rc.12
version: 1.0.0-rc.12
@@ -1937,6 +1940,10 @@ packages:
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-KJ/Dmo1lDDhmW2XDPMo+9oiy/CeqosPguPCrgcVzKyZrL6pM1gU2GmPY/xo6OQPTUaA/c0kwHuywB4E6nmT9ww==}
+ engines: {node: '>=10.6.0'}
+
resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==}
engines: {node: '>= 0.4'}
@@ -4369,8 +4376,8 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
- resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==}
+ resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==}
engines: {node: '>=14.17'}
hasBin: true
@@ -6917,6 +6924,8 @@ snapshots:
+
dependencies:
es-define-property: 1.0.0
@@ -8927,7 +8936,7 @@ snapshots:
csv-parse: 5.5.6
gpt3-tokenizer: 1.1.5
openai: 3.3.0
- typescript: 5.5.3
+ typescript: 5.5.4
uuid: 9.0.1
zod: 3.23.8
transitivePeerDependencies:
@@ -9519,7 +9528,7 @@ snapshots:
dependencies:
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index aab3d1880..7154c6943 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -88,7 +88,15 @@ export async function supaAuthenticateUser(
// console.log('Key and Price ID:', data);
}
- if (error || !data || data.length === 0) {
+ if(error) {
+ return {
+ success: false,
+ error: "Unauthorized: Invalid token or server error.",
+ status: 500,
+ };
+ }
+
+ if (!data || data.length === 0) {
return {
success: false,
error: "Unauthorized: Invalid token",
@@ -178,7 +186,16 @@ export async function supaAuthenticateUser(
.select("*")
.eq("key", normalizedApi);
- if (error || !data || data.length === 0) {
+ if (error) {
+ Logger.warn(`Error fetching api key: ${error.message}`);
+ return {
+ success: false,
+ error: "Unauthorized: Invalid token or server error.",
+ status: 500,
+ };
+ }
+
+ if (!data || data.length === 0) {
return {
success: false,
error: "Unauthorized: Invalid token",
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 3fba86f8a..ebe6ef389 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -10,6 +10,9 @@ import os from "os";
import { Logger } from "./lib/logger";
import { adminRouter } from "./routes/admin";
import { ScrapeEvents } from "./lib/scrape-events";
+import http from 'node:http';
+import https from 'node:https';
+import CacheableLookup from 'cacheable-lookup';
const { createBullBoard } = require("@bull-board/api");
const { BullAdapter } = require("@bull-board/api/bullAdapter");
@@ -18,6 +21,14 @@ const { ExpressAdapter } = require("@bull-board/express");
const numCPUs = process.env.ENV === "local" ? 2 : os.cpus().length;
Logger.info(`Number of CPUs: ${numCPUs} available`);
+const cacheable = new CacheableLookup({
+ // this is important to avoid querying local hostnames see https://github.com/szmarczak/cacheable-lookup readme
+ lookup:false
+});
+
+cacheable.install(http.globalAgent);
+cacheable.install(https.globalAgent)
+
if (cluster.isMaster) {
Logger.info(`Master ${process.pid} is running`);