heliumts 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/helium.js +3 -2
- package/dist/bin/helium.js.map +1 -1
- package/dist/server/ipExtractor.d.ts +48 -0
- package/dist/server/ipExtractor.d.ts.map +1 -0
- package/dist/server/ipExtractor.js +96 -0
- package/dist/server/ipExtractor.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +1 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +2 -0
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/formatError.d.ts +2 -0
- package/dist/utils/formatError.d.ts.map +1 -0
- package/dist/utils/formatError.js +18 -0
- package/dist/utils/formatError.js.map +1 -0
- package/package.json +1 -1
package/dist/bin/helium.js
CHANGED
|
@@ -78,7 +78,7 @@ cli.command("build", "Build for production").action(async () => {
|
|
|
78
78
|
log("info", "Building server...");
|
|
79
79
|
// Generate server entry
|
|
80
80
|
const serverExports = scanServerExports(root);
|
|
81
|
-
const manifestCode = generateServerManifest(serverExports.methods, serverExports.httpHandlers, serverExports.middleware);
|
|
81
|
+
const manifestCode = generateServerManifest(serverExports.methods, serverExports.httpHandlers, serverExports.middleware, serverExports.workers);
|
|
82
82
|
// Create the main server module that will be imported after env is loaded
|
|
83
83
|
const serverModuleCode = `
|
|
84
84
|
import { startProdServer, loadConfig } from 'heliumts/server';
|
|
@@ -96,7 +96,8 @@ export async function start() {
|
|
|
96
96
|
registry.setMiddleware(middlewareHandler);
|
|
97
97
|
httpRouter.setMiddleware(middlewareHandler);
|
|
98
98
|
}
|
|
99
|
-
}
|
|
99
|
+
},
|
|
100
|
+
workers
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
`;
|
package/dist/bin/helium.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helium.js","sourceRoot":"","sources":["../../src/bin/helium.ts"],"names":[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cesContent":["#!/usr/bin/env node\nimport { cac } from \"cac\";\nimport { spawn } from \"child_process\";\nimport { build as esbuild } from \"esbuild\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { build as viteBuild } from \"vite\";\n\nimport { log } from \"../utils/logger.js\";\nimport { scanServerExports } from \"../vite/scanner.js\";\nimport { generateStaticPages } from \"../vite/ssg.js\";\nimport { generateServerManifest } from \"../vite/virtualServerModule.js\";\n\nconst cli = cac(\"helium\");\nconst root = process.cwd();\n\ncli.command(\"dev\", \"Start development server\").action(async () => {\n const vite = spawn(\"vite\", [], { stdio: \"inherit\", shell: true });\n vite.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.command(\"build\", \"Build for production\").action(async () => {\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"Building client...\");\n\n try {\n const result = await viteBuild({\n root,\n logLevel: \"silent\",\n build: {\n outDir: \"dist\",\n },\n });\n\n // Display build output\n if (result && \"output\" in result) {\n const outputs = result.output;\n const zlib = await import(\"zlib\");\n\n for (const chunk of outputs) {\n if (chunk.type === \"asset\" || chunk.type === \"chunk\") {\n const fileName = chunk.fileName;\n const content = \"code\" in chunk ? chunk.code : chunk.source;\n const size = Buffer.byteLength(content, \"utf-8\");\n const sizeKB = (size / 1024).toFixed(2);\n\n // Calculate gzipped size\n const gzipped = zlib.gzipSync(content);\n const gzipSizeKB = (gzipped.length / 1024).toFixed(2);\n\n log(\"info\", ` ${fileName.padEnd(35)} ${sizeKB.padStart(8)} kB │ gzip: ${gzipSizeKB.padStart(7)} kB`);\n }\n }\n }\n\n log(\"info\", \"Client build complete.\");\n\n // Generate static pages for SSG\n log(\"info\", \"--------------------------------\");\n try {\n // Read the generated index.html as a template for SSG\n const distDir = path.join(root, \"dist\");\n const htmlPath = path.join(distDir, \"index.html\");\n\n if (fs.existsSync(htmlPath)) {\n let htmlTemplate = fs.readFileSync(htmlPath, \"utf-8\");\n\n // Clean up the template for SSG:\n // 1. Remove the build-time HELIUM_CONNECTION_TOKEN (SSG pages don't need it)\n htmlTemplate = htmlTemplate.replace(/<script>window\\.HELIUM_CONNECTION_TOKEN = \"build-time-placeholder\";<\\/script>/g, \"\");\n\n // 2. Clear any existing content in root div from SPA build\n htmlTemplate = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>.*?<\\/div>/s, '<div id=\"root\"></div>');\n\n await generateStaticPages(null, root, htmlTemplate, distDir);\n } else {\n log(\"warn\", \"index.html not found in dist, skipping SSG\");\n }\n } catch (e) {\n log(\"warn\", \"SSG generation failed:\", e);\n // Don't fail the build if SSG fails\n }\n log(\"info\", \"--------------------------------\");\n } catch (e) {\n log(\"error\", \"Client build failed:\", e);\n process.exit(1);\n }\n\n log(\"info\", \"Building server...\");\n // Generate server entry\n const serverExports = scanServerExports(root);\n const manifestCode = generateServerManifest(serverExports.methods, serverExports.httpHandlers, serverExports.middleware);\n\n // Create the main server module that will be imported after env is loaded\n const serverModuleCode = `\nimport { startProdServer, loadConfig } from 'heliumts/server';\n${manifestCode}\n\nexport async function start() {\n const config = await loadConfig();\n\n startProdServer({\n config,\n registerHandlers: (registry, httpRouter) => {\n registerAll(registry);\n httpRouter.registerRoutes(httpHandlers);\n if (middlewareHandler) {\n registry.setMiddleware(middlewareHandler);\n httpRouter.setMiddleware(middlewareHandler);\n }\n }\n });\n}\n`;\n\n // Create the entry loader that loads env first, then imports the server module\n const entryCode = `\n// Load environment variables FIRST, before any other imports\nimport './env-loader.js';\n// Now import and start the server (this ensures handlers load after env)\nimport { start } from './server-module.js';\nawait start();\n`;\n\n const envLoaderCode = `\nimport { loadEnvFiles, injectEnvToProcess, log } from 'heliumts/server';\nconst envRoot = process.cwd();\nlog('info', \\`Loading .env files from: \\${envRoot}\\`);\nconst envVars = loadEnvFiles({ mode: 'production' });\ninjectEnvToProcess(envVars);\nif (Object.keys(envVars).length > 0) {\n log('info', \\`Loaded \\${Object.keys(envVars).length} environment variable(s) from .env files\\`);\n} else {\n log('info', 'No .env files found (using platform environment variables if available)');\n}\n`;\n\n const heliumDir = path.join(root, \"node_modules\", \".heliumts\");\n if (!fs.existsSync(heliumDir)) {\n fs.mkdirSync(heliumDir, { recursive: true });\n }\n const entryPath = path.join(heliumDir, \"server-entry.ts\");\n const envLoaderPath = path.join(heliumDir, \"env-loader.ts\");\n const serverModuleSrcPath = path.join(heliumDir, \"server-module.ts\");\n\n fs.writeFileSync(entryPath, entryCode);\n fs.writeFileSync(envLoaderPath, envLoaderCode);\n fs.writeFileSync(serverModuleSrcPath, serverModuleCode);\n\n // Bundle with esbuild\n try {\n await esbuild({\n entryPoints: [entryPath],\n outfile: path.join(root, \"dist\", \"server.js\"),\n bundle: true,\n platform: \"node\",\n format: \"esm\",\n external: [\n // External common database and heavy dependencies\n \"mongodb\",\n \"mongoose\",\n \"pg\",\n \"mysql\",\n \"mysql2\",\n \"sqlite3\",\n \"better-sqlite3\",\n \"redis\",\n // Node.js built-ins are automatically external, but let's be explicit\n \"crypto\",\n \"fs\",\n \"path\",\n \"http\",\n \"https\",\n \"stream\",\n \"zlib\",\n \"util\",\n ],\n target: \"node18\",\n metafile: true,\n banner: {\n js: \"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\",\n },\n });\n\n // Display server build output\n const serverOutputPath = path.relative(root, path.join(root, \"dist\", \"server.js\"));\n const serverStats = fs.statSync(path.join(root, \"dist\", \"server.js\"));\n const serverSizeKB = (serverStats.size / 1024).toFixed(2);\n log(\"info\", ` ${serverOutputPath.padEnd(35)} ${serverSizeKB.padStart(8)} kB`);\n\n log(\"info\", \"Server build complete.\");\n\n // Transpile helium.config.ts to helium.config.js if it exists\n const configTsPath = path.join(root, \"helium.config.ts\");\n if (fs.existsSync(configTsPath)) {\n log(\"info\", \"Transpiling helium.config.ts...\");\n try {\n await esbuild({\n entryPoints: [configTsPath],\n outfile: path.join(root, \"dist\", \"helium.config.js\"),\n bundle: false,\n platform: \"node\",\n format: \"esm\",\n target: \"node18\",\n });\n log(\"info\", \"Config file transpiled to dist/helium.config.js\");\n } catch (e) {\n log(\"warn\", \"Failed to transpile config file:\", e);\n log(\"warn\", \"You may need to manually rename helium.config.ts to helium.config.js\");\n }\n } else {\n // Check if .js or .mjs config exists and copy it to dist\n const configJsPath = path.join(root, \"helium.config.js\");\n const configMjsPath = path.join(root, \"helium.config.mjs\");\n\n if (fs.existsSync(configJsPath)) {\n fs.copyFileSync(configJsPath, path.join(root, \"dist\", \"helium.config.js\"));\n log(\"info\", \"Copied helium.config.js to dist/\");\n } else if (fs.existsSync(configMjsPath)) {\n fs.copyFileSync(configMjsPath, path.join(root, \"dist\", \"helium.config.mjs\"));\n log(\"info\", \"Copied helium.config.mjs to dist/\");\n }\n }\n\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"✓ Build finished successfully.\");\n log(\"info\", \"▶ Run 'helium start' to start the production server.\");\n\n // Exit cleanly after build completes\n process.exit(0);\n } catch (e) {\n log(\"error\", \"Server build failed:\", e);\n process.exit(1);\n }\n});\n\ncli.command(\"start\", \"Start production server\").action(async () => {\n const serverPath = path.join(root, \"dist\", \"server.js\");\n if (!fs.existsSync(serverPath)) {\n log(\"error\", 'Server build not found. Run \"helium build\" first.');\n process.exit(1);\n }\n\n // When running in production, look for config in dist directory first\n // This allows the transpiled config to be found\n const server = spawn(\"node\", [serverPath], {\n stdio: \"inherit\",\n shell: true,\n env: { ...process.env, HELIUM_CONFIG_DIR: path.join(root, \"dist\") },\n });\n server.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.help();\ncli.parse();\n"]}
|
|
1
|
+
{"version":3,"file":"helium.js","sourceRoot":"","sources":["../../src/bin/helium.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAA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AAG,CAAC,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACxD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,GAAG,CAAC,OAAO,EAAE,mDAAmD,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,sEAAsE;IACtE,gDAAgD;IAChD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE;QACvC,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;KACtE,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,IAAI,EAAE,CAAC;AACX,GAAG,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { cac } from \"cac\";\nimport { spawn } from \"child_process\";\nimport { build as esbuild } from \"esbuild\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { build as viteBuild } from \"vite\";\n\nimport { log } from \"../utils/logger.js\";\nimport { scanServerExports } from \"../vite/scanner.js\";\nimport { generateStaticPages } from \"../vite/ssg.js\";\nimport { generateServerManifest } from \"../vite/virtualServerModule.js\";\n\nconst cli = cac(\"helium\");\nconst root = process.cwd();\n\ncli.command(\"dev\", \"Start development server\").action(async () => {\n const vite = spawn(\"vite\", [], { stdio: \"inherit\", shell: true });\n vite.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.command(\"build\", \"Build for production\").action(async () => {\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"Building client...\");\n\n try {\n const result = await viteBuild({\n root,\n logLevel: \"silent\",\n build: {\n outDir: \"dist\",\n },\n });\n\n // Display build output\n if (result && \"output\" in result) {\n const outputs = result.output;\n const zlib = await import(\"zlib\");\n\n for (const chunk of outputs) {\n if (chunk.type === \"asset\" || chunk.type === \"chunk\") {\n const fileName = chunk.fileName;\n const content = \"code\" in chunk ? chunk.code : chunk.source;\n const size = Buffer.byteLength(content, \"utf-8\");\n const sizeKB = (size / 1024).toFixed(2);\n\n // Calculate gzipped size\n const gzipped = zlib.gzipSync(content);\n const gzipSizeKB = (gzipped.length / 1024).toFixed(2);\n\n log(\"info\", ` ${fileName.padEnd(35)} ${sizeKB.padStart(8)} kB │ gzip: ${gzipSizeKB.padStart(7)} kB`);\n }\n }\n }\n\n log(\"info\", \"Client build complete.\");\n\n // Generate static pages for SSG\n log(\"info\", \"--------------------------------\");\n try {\n // Read the generated index.html as a template for SSG\n const distDir = path.join(root, \"dist\");\n const htmlPath = path.join(distDir, \"index.html\");\n\n if (fs.existsSync(htmlPath)) {\n let htmlTemplate = fs.readFileSync(htmlPath, \"utf-8\");\n\n // Clean up the template for SSG:\n // 1. Remove the build-time HELIUM_CONNECTION_TOKEN (SSG pages don't need it)\n htmlTemplate = htmlTemplate.replace(/<script>window\\.HELIUM_CONNECTION_TOKEN = \"build-time-placeholder\";<\\/script>/g, \"\");\n\n // 2. Clear any existing content in root div from SPA build\n htmlTemplate = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>.*?<\\/div>/s, '<div id=\"root\"></div>');\n\n await generateStaticPages(null, root, htmlTemplate, distDir);\n } else {\n log(\"warn\", \"index.html not found in dist, skipping SSG\");\n }\n } catch (e) {\n log(\"warn\", \"SSG generation failed:\", e);\n // Don't fail the build if SSG fails\n }\n log(\"info\", \"--------------------------------\");\n } catch (e) {\n log(\"error\", \"Client build failed:\", e);\n process.exit(1);\n }\n\n log(\"info\", \"Building server...\");\n // Generate server entry\n const serverExports = scanServerExports(root);\n const manifestCode = generateServerManifest(serverExports.methods, serverExports.httpHandlers, serverExports.middleware, serverExports.workers);\n\n // Create the main server module that will be imported after env is loaded\n const serverModuleCode = `\nimport { startProdServer, loadConfig } from 'heliumts/server';\n${manifestCode}\n\nexport async function start() {\n const config = await loadConfig();\n\n startProdServer({\n config,\n registerHandlers: (registry, httpRouter) => {\n registerAll(registry);\n httpRouter.registerRoutes(httpHandlers);\n if (middlewareHandler) {\n registry.setMiddleware(middlewareHandler);\n httpRouter.setMiddleware(middlewareHandler);\n }\n },\n workers\n });\n}\n`;\n\n // Create the entry loader that loads env first, then imports the server module\n const entryCode = `\n// Load environment variables FIRST, before any other imports\nimport './env-loader.js';\n// Now import and start the server (this ensures handlers load after env)\nimport { start } from './server-module.js';\nawait start();\n`;\n\n const envLoaderCode = `\nimport { loadEnvFiles, injectEnvToProcess, log } from 'heliumts/server';\nconst envRoot = process.cwd();\nlog('info', \\`Loading .env files from: \\${envRoot}\\`);\nconst envVars = loadEnvFiles({ mode: 'production' });\ninjectEnvToProcess(envVars);\nif (Object.keys(envVars).length > 0) {\n log('info', \\`Loaded \\${Object.keys(envVars).length} environment variable(s) from .env files\\`);\n} else {\n log('info', 'No .env files found (using platform environment variables if available)');\n}\n`;\n\n const heliumDir = path.join(root, \"node_modules\", \".heliumts\");\n if (!fs.existsSync(heliumDir)) {\n fs.mkdirSync(heliumDir, { recursive: true });\n }\n const entryPath = path.join(heliumDir, \"server-entry.ts\");\n const envLoaderPath = path.join(heliumDir, \"env-loader.ts\");\n const serverModuleSrcPath = path.join(heliumDir, \"server-module.ts\");\n\n fs.writeFileSync(entryPath, entryCode);\n fs.writeFileSync(envLoaderPath, envLoaderCode);\n fs.writeFileSync(serverModuleSrcPath, serverModuleCode);\n\n // Bundle with esbuild\n try {\n await esbuild({\n entryPoints: [entryPath],\n outfile: path.join(root, \"dist\", \"server.js\"),\n bundle: true,\n platform: \"node\",\n format: \"esm\",\n external: [\n // External common database and heavy dependencies\n \"mongodb\",\n \"mongoose\",\n \"pg\",\n \"mysql\",\n \"mysql2\",\n \"sqlite3\",\n \"better-sqlite3\",\n \"redis\",\n // Node.js built-ins are automatically external, but let's be explicit\n \"crypto\",\n \"fs\",\n \"path\",\n \"http\",\n \"https\",\n \"stream\",\n \"zlib\",\n \"util\",\n ],\n target: \"node18\",\n metafile: true,\n banner: {\n js: \"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\",\n },\n });\n\n // Display server build output\n const serverOutputPath = path.relative(root, path.join(root, \"dist\", \"server.js\"));\n const serverStats = fs.statSync(path.join(root, \"dist\", \"server.js\"));\n const serverSizeKB = (serverStats.size / 1024).toFixed(2);\n log(\"info\", ` ${serverOutputPath.padEnd(35)} ${serverSizeKB.padStart(8)} kB`);\n\n log(\"info\", \"Server build complete.\");\n\n // Transpile helium.config.ts to helium.config.js if it exists\n const configTsPath = path.join(root, \"helium.config.ts\");\n if (fs.existsSync(configTsPath)) {\n log(\"info\", \"Transpiling helium.config.ts...\");\n try {\n await esbuild({\n entryPoints: [configTsPath],\n outfile: path.join(root, \"dist\", \"helium.config.js\"),\n bundle: false,\n platform: \"node\",\n format: \"esm\",\n target: \"node18\",\n });\n log(\"info\", \"Config file transpiled to dist/helium.config.js\");\n } catch (e) {\n log(\"warn\", \"Failed to transpile config file:\", e);\n log(\"warn\", \"You may need to manually rename helium.config.ts to helium.config.js\");\n }\n } else {\n // Check if .js or .mjs config exists and copy it to dist\n const configJsPath = path.join(root, \"helium.config.js\");\n const configMjsPath = path.join(root, \"helium.config.mjs\");\n\n if (fs.existsSync(configJsPath)) {\n fs.copyFileSync(configJsPath, path.join(root, \"dist\", \"helium.config.js\"));\n log(\"info\", \"Copied helium.config.js to dist/\");\n } else if (fs.existsSync(configMjsPath)) {\n fs.copyFileSync(configMjsPath, path.join(root, \"dist\", \"helium.config.mjs\"));\n log(\"info\", \"Copied helium.config.mjs to dist/\");\n }\n }\n\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"✓ Build finished successfully.\");\n log(\"info\", \"▶ Run 'helium start' to start the production server.\");\n\n // Exit cleanly after build completes\n process.exit(0);\n } catch (e) {\n log(\"error\", \"Server build failed:\", e);\n process.exit(1);\n }\n});\n\ncli.command(\"start\", \"Start production server\").action(async () => {\n const serverPath = path.join(root, \"dist\", \"server.js\");\n if (!fs.existsSync(serverPath)) {\n log(\"error\", 'Server build not found. Run \"helium build\" first.');\n process.exit(1);\n }\n\n // When running in production, look for config in dist directory first\n // This allows the transpiled config to be found\n const server = spawn(\"node\", [serverPath], {\n stdio: \"inherit\",\n shell: true,\n env: { ...process.env, HELIUM_CONFIG_DIR: path.join(root, \"dist\") },\n });\n server.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.help();\ncli.parse();\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type http from "http";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the client IP address from an HTTP request, taking into account proxy configurations.
|
|
4
|
+
*
|
|
5
|
+
* When behind proxies (like Vercel, Cloudflare, AWS ALB, etc.), the X-Forwarded-For header
|
|
6
|
+
* contains a chain of IP addresses. The format is: "client, proxy1, proxy2, ..."
|
|
7
|
+
*
|
|
8
|
+
* @param req - The HTTP request object
|
|
9
|
+
* @param trustProxyDepth - Number of proxy levels to trust
|
|
10
|
+
* - 0: Only use req.socket.remoteAddress (no proxy trust)
|
|
11
|
+
* - 1: Trust 1 proxy level (get the last IP before your server)
|
|
12
|
+
* - 2+: Trust multiple proxy levels (for complex setups)
|
|
13
|
+
*
|
|
14
|
+
* Examples:
|
|
15
|
+
* - trustProxyDepth=0: Direct connection, no proxies
|
|
16
|
+
* X-Forwarded-For: ignored
|
|
17
|
+
* Result: req.socket.remoteAddress
|
|
18
|
+
*
|
|
19
|
+
* - trustProxyDepth=1: Behind one proxy (e.g., Vercel, Netlify)
|
|
20
|
+
* X-Forwarded-For: "203.0.113.1, 198.51.100.1"
|
|
21
|
+
* Result: "203.0.113.1" (client IP)
|
|
22
|
+
*
|
|
23
|
+
* - trustProxyDepth=2: Behind two proxies (e.g., Cloudflare -> Load Balancer)
|
|
24
|
+
* X-Forwarded-For: "203.0.113.1, 198.51.100.1, 192.0.2.1"
|
|
25
|
+
* Result: "203.0.113.1" (client IP)
|
|
26
|
+
*
|
|
27
|
+
* Common configurations:
|
|
28
|
+
* - Vercel/Netlify/Railway: trustProxyDepth=1
|
|
29
|
+
* - Cloudflare -> Origin: trustProxyDepth=1 or 2 (depending on your setup)
|
|
30
|
+
* - AWS ALB -> EC2: trustProxyDepth=1
|
|
31
|
+
* - Nginx -> Node: trustProxyDepth=1
|
|
32
|
+
* - Cloudflare -> Nginx -> Node: trustProxyDepth=2
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractClientIP(req: http.IncomingMessage, trustProxyDepth?: number): string;
|
|
35
|
+
/**
|
|
36
|
+
* Alternative extraction method that works from the right (trusts the rightmost IPs).
|
|
37
|
+
* This is useful when you want to trust the last N proxies in the chain.
|
|
38
|
+
*
|
|
39
|
+
* @param req - The HTTP request object
|
|
40
|
+
* @param trustProxyDepth - Number of proxy levels to trust from the right
|
|
41
|
+
*
|
|
42
|
+
* Example:
|
|
43
|
+
* X-Forwarded-For: "203.0.113.1, 198.51.100.1, 192.0.2.1"
|
|
44
|
+
* trustProxyDepth=1: Result is "198.51.100.1" (skip the last trusted proxy)
|
|
45
|
+
* trustProxyDepth=2: Result is "203.0.113.1" (skip the last 2 trusted proxies)
|
|
46
|
+
*/
|
|
47
|
+
export declare function extractClientIPFromRight(req: http.IncomingMessage, trustProxyDepth?: number): string;
|
|
48
|
+
//# sourceMappingURL=ipExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipExtractor.d.ts","sourceRoot":"","sources":["../../src/server/ipExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,GAAE,MAAU,GAAG,MAAM,CAqC9F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,GAAE,MAAU,GAAG,MAAM,CAsBvG"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the client IP address from an HTTP request, taking into account proxy configurations.
|
|
3
|
+
*
|
|
4
|
+
* When behind proxies (like Vercel, Cloudflare, AWS ALB, etc.), the X-Forwarded-For header
|
|
5
|
+
* contains a chain of IP addresses. The format is: "client, proxy1, proxy2, ..."
|
|
6
|
+
*
|
|
7
|
+
* @param req - The HTTP request object
|
|
8
|
+
* @param trustProxyDepth - Number of proxy levels to trust
|
|
9
|
+
* - 0: Only use req.socket.remoteAddress (no proxy trust)
|
|
10
|
+
* - 1: Trust 1 proxy level (get the last IP before your server)
|
|
11
|
+
* - 2+: Trust multiple proxy levels (for complex setups)
|
|
12
|
+
*
|
|
13
|
+
* Examples:
|
|
14
|
+
* - trustProxyDepth=0: Direct connection, no proxies
|
|
15
|
+
* X-Forwarded-For: ignored
|
|
16
|
+
* Result: req.socket.remoteAddress
|
|
17
|
+
*
|
|
18
|
+
* - trustProxyDepth=1: Behind one proxy (e.g., Vercel, Netlify)
|
|
19
|
+
* X-Forwarded-For: "203.0.113.1, 198.51.100.1"
|
|
20
|
+
* Result: "203.0.113.1" (client IP)
|
|
21
|
+
*
|
|
22
|
+
* - trustProxyDepth=2: Behind two proxies (e.g., Cloudflare -> Load Balancer)
|
|
23
|
+
* X-Forwarded-For: "203.0.113.1, 198.51.100.1, 192.0.2.1"
|
|
24
|
+
* Result: "203.0.113.1" (client IP)
|
|
25
|
+
*
|
|
26
|
+
* Common configurations:
|
|
27
|
+
* - Vercel/Netlify/Railway: trustProxyDepth=1
|
|
28
|
+
* - Cloudflare -> Origin: trustProxyDepth=1 or 2 (depending on your setup)
|
|
29
|
+
* - AWS ALB -> EC2: trustProxyDepth=1
|
|
30
|
+
* - Nginx -> Node: trustProxyDepth=1
|
|
31
|
+
* - Cloudflare -> Nginx -> Node: trustProxyDepth=2
|
|
32
|
+
*/
|
|
33
|
+
export function extractClientIP(req, trustProxyDepth = 0) {
|
|
34
|
+
// If not trusting any proxies, return the direct connection IP
|
|
35
|
+
if (trustProxyDepth === 0) {
|
|
36
|
+
return req.socket.remoteAddress || "unknown";
|
|
37
|
+
}
|
|
38
|
+
// Get X-Forwarded-For header
|
|
39
|
+
const forwardedFor = req.headers["x-forwarded-for"];
|
|
40
|
+
if (!forwardedFor) {
|
|
41
|
+
// No X-Forwarded-For header, fall back to direct connection
|
|
42
|
+
return req.socket.remoteAddress || "unknown";
|
|
43
|
+
}
|
|
44
|
+
// Parse X-Forwarded-For header (can be a string or array of strings)
|
|
45
|
+
const forwardedIPs = (Array.isArray(forwardedFor) ? forwardedFor.join(",") : forwardedFor)
|
|
46
|
+
.split(",")
|
|
47
|
+
.map((ip) => ip.trim())
|
|
48
|
+
.filter((ip) => ip.length > 0);
|
|
49
|
+
if (forwardedIPs.length === 0) {
|
|
50
|
+
// Empty X-Forwarded-For, fall back to direct connection
|
|
51
|
+
return req.socket.remoteAddress || "unknown";
|
|
52
|
+
}
|
|
53
|
+
// The client IP is at the beginning of the chain
|
|
54
|
+
// We trust the chain up to trustProxyDepth levels
|
|
55
|
+
// Format: [clientIP, proxy1, proxy2, ..., lastProxy]
|
|
56
|
+
// We want the clientIP, but we need to verify we have enough trusted proxies
|
|
57
|
+
if (forwardedIPs.length < trustProxyDepth) {
|
|
58
|
+
// Not enough IPs in the chain, the chain might be incomplete or spoofed
|
|
59
|
+
// Fall back to direct connection for safety
|
|
60
|
+
return req.socket.remoteAddress || "unknown";
|
|
61
|
+
}
|
|
62
|
+
// Return the client IP (first in the chain)
|
|
63
|
+
return forwardedIPs[0];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Alternative extraction method that works from the right (trusts the rightmost IPs).
|
|
67
|
+
* This is useful when you want to trust the last N proxies in the chain.
|
|
68
|
+
*
|
|
69
|
+
* @param req - The HTTP request object
|
|
70
|
+
* @param trustProxyDepth - Number of proxy levels to trust from the right
|
|
71
|
+
*
|
|
72
|
+
* Example:
|
|
73
|
+
* X-Forwarded-For: "203.0.113.1, 198.51.100.1, 192.0.2.1"
|
|
74
|
+
* trustProxyDepth=1: Result is "198.51.100.1" (skip the last trusted proxy)
|
|
75
|
+
* trustProxyDepth=2: Result is "203.0.113.1" (skip the last 2 trusted proxies)
|
|
76
|
+
*/
|
|
77
|
+
export function extractClientIPFromRight(req, trustProxyDepth = 0) {
|
|
78
|
+
if (trustProxyDepth === 0) {
|
|
79
|
+
return req.socket.remoteAddress || "unknown";
|
|
80
|
+
}
|
|
81
|
+
const forwardedFor = req.headers["x-forwarded-for"];
|
|
82
|
+
if (!forwardedFor) {
|
|
83
|
+
return req.socket.remoteAddress || "unknown";
|
|
84
|
+
}
|
|
85
|
+
const forwardedIPs = (Array.isArray(forwardedFor) ? forwardedFor.join(",") : forwardedFor)
|
|
86
|
+
.split(",")
|
|
87
|
+
.map((ip) => ip.trim())
|
|
88
|
+
.filter((ip) => ip.length > 0);
|
|
89
|
+
if (forwardedIPs.length === 0) {
|
|
90
|
+
return req.socket.remoteAddress || "unknown";
|
|
91
|
+
}
|
|
92
|
+
// Calculate which IP to trust by skipping the rightmost N trusted proxies
|
|
93
|
+
const clientIPIndex = Math.max(0, forwardedIPs.length - trustProxyDepth - 1);
|
|
94
|
+
return forwardedIPs[clientIPIndex];
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=ipExtractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipExtractor.js","sourceRoot":"","sources":["../../src/server/ipExtractor.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,eAAe,CAAC,GAAyB,EAAE,kBAA0B,CAAC;IAClF,+DAA+D;IAC/D,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,SAAS,CAAC;IACjD,CAAC;IAED,6BAA6B;IAC7B,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACpD,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,4DAA4D;QAC5D,OAAO,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,SAAS,CAAC;IACjD,CAAC;IAED,qEAAqE;IACrE,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;SACrF,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;SACtB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEnC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,wDAAwD;QACxD,OAAO,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,SAAS,CAAC;IACjD,CAAC;IAED,iDAAiD;IACjD,kDAAkD;IAClD,qDAAqD;IACrD,6EAA6E;IAE7E,IAAI,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C;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=deepEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.d.ts","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.js","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatError.d.ts","sourceRoot":"","sources":["../../src/utils/formatError.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAgBhD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function formatError(err) {
|
|
2
|
+
console.log("🚀 ~ formatError ~ err:", err);
|
|
3
|
+
if (err instanceof Error) {
|
|
4
|
+
return err.message;
|
|
5
|
+
}
|
|
6
|
+
if (typeof err === "object" && err !== null) {
|
|
7
|
+
if ("message" in err) {
|
|
8
|
+
return String(err.message);
|
|
9
|
+
}
|
|
10
|
+
// Format Record<string, string> errors
|
|
11
|
+
return JSON.stringify(err, null, 2);
|
|
12
|
+
}
|
|
13
|
+
if (typeof err === "string") {
|
|
14
|
+
return err;
|
|
15
|
+
}
|
|
16
|
+
return String(err);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=formatError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatError.js","sourceRoot":"","sources":["../../src/utils/formatError.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,GAAY;IACpC,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAC5C,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC1C,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,uCAAuC;QACvC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
|