@faapi/faapi 0.0.0-canary.0f443f9 → 0.0.0-canary.4ab8d97

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/cli/index.js CHANGED
@@ -1233,7 +1233,7 @@ function formatSetCookie(name, value, options) {
1233
1233
  if (options?.sameSite) cookie += `; SameSite=${options.sameSite}`;
1234
1234
  return cookie;
1235
1235
  }
1236
- function createContext(request, params, config = {}, ip = "") {
1236
+ function createContext(request, params, config = {}) {
1237
1237
  const url = new URL(request.url);
1238
1238
  const meta = { headers: {}, setCookies: [] };
1239
1239
  const parsedCookies = parseCookies(request.headers.get("cookie") ?? "");
@@ -1248,7 +1248,6 @@ function createContext(request, params, config = {}, ip = "") {
1248
1248
  headers: request.headers,
1249
1249
  method: request.method,
1250
1250
  path: url.pathname,
1251
- ip,
1252
1251
  cookies: cookiesObj,
1253
1252
  config,
1254
1253
  meta,
@@ -1706,7 +1705,6 @@ var init_resolveInjection = __esm({
1706
1705
  ctx: "context",
1707
1706
  // 别名
1708
1707
  cookies: "cookies",
1709
- ip: "ip",
1710
1708
  files: "files",
1711
1709
  fields: "fields"
1712
1710
  };
@@ -1726,8 +1724,6 @@ function getBuiltinInjectionValue(type, ctx, body) {
1726
1724
  return ctx;
1727
1725
  case "cookies":
1728
1726
  return ctx.cookies;
1729
- case "ip":
1730
- return ctx.ip;
1731
1727
  case "body":
1732
1728
  return body;
1733
1729
  case "files":
@@ -2134,28 +2130,6 @@ var init_validateInput = __esm({
2134
2130
  }
2135
2131
  });
2136
2132
 
2137
- // src/utils/getClientIp.ts
2138
- function getClientIp(req) {
2139
- const xff = req.headers["x-forwarded-for"];
2140
- if (typeof xff === "string" && xff.length > 0) {
2141
- const first = xff.split(",")[0]?.trim();
2142
- if (first) return first;
2143
- }
2144
- const remote = req.socket.remoteAddress;
2145
- if (remote) {
2146
- if (remote.startsWith("::ffff:")) {
2147
- return remote.slice(7);
2148
- }
2149
- return remote;
2150
- }
2151
- return "";
2152
- }
2153
- var init_getClientIp = __esm({
2154
- "src/utils/getClientIp.ts"() {
2155
- "use strict";
2156
- }
2157
- });
2158
-
2159
2133
  // src/middleware/cors.ts
2160
2134
  function cors(options = {}) {
2161
2135
  const {
@@ -3493,7 +3467,7 @@ function attachWebSocket(options) {
3493
3467
  const host = req.headers.host ?? "localhost";
3494
3468
  const url = `http://${host}${req.url ?? "/"}`;
3495
3469
  const request = new Request(url, { method: "GET", headers });
3496
- const ctx = createContext(request, params, config, getClientIp(req));
3470
+ const ctx = createContext(request, params, config);
3497
3471
  const meta = ctx.meta;
3498
3472
  let upgraded = false;
3499
3473
  const finalHandler = async () => {
@@ -3550,7 +3524,6 @@ var init_handleWsUpgrade = __esm({
3550
3524
  init_createContext();
3551
3525
  init_invokeHandler();
3552
3526
  init_importWithCacheBust();
3553
- init_getClientIp();
3554
3527
  init_serverUtils();
3555
3528
  init_wsHandler();
3556
3529
  }
@@ -3674,7 +3647,7 @@ async function handleRequest(routes, rootDir, req, res, corsMiddleware, staticDi
3674
3647
  const request = toWebRequest(req);
3675
3648
  const method = request.method.toUpperCase();
3676
3649
  const urlPath = new URL(request.url).pathname;
3677
- const ctx = createContext(request, {}, config, getClientIp(req));
3650
+ const ctx = createContext(request, {}, config);
3678
3651
  const meta = ctx.meta;
3679
3652
  const routePipeline = async () => {
3680
3653
  const match = matchRoute(routes, method, urlPath);
@@ -3759,7 +3732,6 @@ var init_createServer = __esm({
3759
3732
  init_httpErrors();
3760
3733
  init_validateInput();
3761
3734
  init_inputType();
3762
- init_getClientIp();
3763
3735
  init_cors();
3764
3736
  init_serveStatic();
3765
3737
  init_schemaRegistry();