@faapi/faapi 6.26.0 → 6.27.0

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
@@ -7080,18 +7080,10 @@ function formatSetCookie(name, value, options) {
7080
7080
  if (options?.sameSite) cookie += `; SameSite=${options.sameSite}`;
7081
7081
  return cookie;
7082
7082
  }
7083
- function createContext(request, params, config = {}, ip = "", registries, resourcesDir) {
7084
- return createContextFromUrl(
7085
- request,
7086
- new URL(request.url),
7087
- params,
7088
- config,
7089
- ip,
7090
- registries,
7091
- resourcesDir
7092
- );
7083
+ function createContext(request, params, config = {}, ip = "", registries) {
7084
+ return createContextFromUrl(request, new URL(request.url), params, config, ip, registries);
7093
7085
  }
7094
- function createContextFromUrl(request, url, params, config = {}, ip = "", registries, resourcesDir) {
7086
+ function createContextFromUrl(request, url, params, config = {}, ip = "", registries) {
7095
7087
  const meta = { headers: {}, setCookies: [] };
7096
7088
  const parsedCookies = parseCookies(request.headers.get("cookie") ?? "");
7097
7089
  const cookiesObj = {};
@@ -7119,9 +7111,6 @@ function createContextFromUrl(request, url, params, config = {}, ip = "", regist
7119
7111
  ua: request.headers.get("user-agent") ?? "",
7120
7112
  cookies: cookiesObj,
7121
7113
  config,
7122
- // 运行时资源根目录(HTTP/WS 链路由 createServer/handleWsUpgrade 传入;
7123
- // testing 直调未传时为 undefined,见 contextTypes.resourcesDir 注释)
7124
- resourcesDir,
7125
7114
  meta,
7126
7115
  setStatus(status) {
7127
7116
  meta.status = status;
@@ -8657,7 +8646,6 @@ function attachWebSocket(options) {
8657
8646
  trustedProxy = false,
8658
8647
  registries
8659
8648
  } = options;
8660
- const resourcesDir = resolveResourcesDir(rootDir, dist);
8661
8649
  const wss = new WebSocketServer({ noServer: true });
8662
8650
  server.on("upgrade", async (req, socket, head) => {
8663
8651
  try {
@@ -8689,14 +8677,7 @@ function attachWebSocket(options) {
8689
8677
  const host = req.headers.host ?? "localhost";
8690
8678
  const fullUrl = new URL(`http://${host}${req.url ?? "/"}`);
8691
8679
  const request = new Request(fullUrl.toString(), { method: "GET", headers });
8692
- const ctx = createContext(
8693
- request,
8694
- params,
8695
- config,
8696
- getClientIp(req, trustedProxy),
8697
- registries,
8698
- resourcesDir
8699
- );
8680
+ const ctx = createContext(request, params, config, getClientIp(req, trustedProxy), registries);
8700
8681
  const meta = ctx.meta;
8701
8682
  let upgraded = false;
8702
8683
  const finalHandler = async () => {
@@ -8798,7 +8779,6 @@ var init_handleWsUpgrade = __esm({
8798
8779
  "use strict";
8799
8780
  init_matchRoute();
8800
8781
  init_createContext();
8801
- init_copyResources();
8802
8782
  init_invokeHandler();
8803
8783
  init_importWithCacheBust();
8804
8784
  init_getClientIp();
@@ -8925,7 +8905,6 @@ function createServer(options) {
8925
8905
  trustedProxy = false
8926
8906
  } = options;
8927
8907
  const routesRef = { current: routes, wsCurrent: wsRoutes ?? [] };
8928
- const resourcesDir = resolveResourcesDir(rootDir, dist);
8929
8908
  const configMiddlewares = [];
8930
8909
  if (compressionOption) {
8931
8910
  const compOpts = typeof compressionOption === "object" ? compressionOption : {};
@@ -8972,8 +8951,7 @@ function createServer(options) {
8972
8951
  bodyLimit,
8973
8952
  trustedProxy,
8974
8953
  registries,
8975
- routesRef.wsCurrent,
8976
- resourcesDir
8954
+ routesRef.wsCurrent
8977
8955
  ).catch((err) => {
8978
8956
  console.error("[faapi] Request pipeline failed after error response attempt:", err);
8979
8957
  try {
@@ -8999,7 +8977,7 @@ function createServer(options) {
8999
8977
  });
9000
8978
  return { server, routesRef };
9001
8979
  }
9002
- function prepareRequest(req, request, url, config, trustedProxy, registries, preMatched, resourcesDir) {
8980
+ function prepareRequest(req, request, url, config, trustedProxy, registries, preMatched) {
9003
8981
  const method = request.method.toUpperCase();
9004
8982
  const urlPath = url.pathname;
9005
8983
  const ctx = createContextFromUrl(
@@ -9008,8 +8986,7 @@ function prepareRequest(req, request, url, config, trustedProxy, registries, pre
9008
8986
  preMatched?.params ?? {},
9009
8987
  config,
9010
8988
  getClientIp(req, trustedProxy),
9011
- registries,
9012
- resourcesDir
8989
+ registries
9013
8990
  );
9014
8991
  const meta = ctx.meta;
9015
8992
  return { request, url, ctx, meta, method, urlPath };
@@ -9149,7 +9126,7 @@ async function sendErrorResponse(err, meta, res, onError, ctx) {
9149
9126
  }
9150
9127
  }
9151
9128
  }
9152
- async function handleRequest(routes, rootDir, dist, req, res, outerMiddlewares, onError, config, globalInjectors, bodyLimit, trustedProxy, registries, wsRoutes, resourcesDir) {
9129
+ async function handleRequest(routes, rootDir, dist, req, res, outerMiddlewares, onError, config, globalInjectors, bodyLimit, trustedProxy, registries, wsRoutes) {
9153
9130
  let meta = { headers: {}, setCookies: [] };
9154
9131
  let ctx;
9155
9132
  let sseEarlySent = false;
@@ -9169,8 +9146,7 @@ async function handleRequest(routes, rootDir, dist, req, res, outerMiddlewares,
9169
9146
  config,
9170
9147
  trustedProxy,
9171
9148
  registries,
9172
- preMatched,
9173
- resourcesDir
9149
+ preMatched
9174
9150
  );
9175
9151
  ctx = prepared.ctx;
9176
9152
  meta = prepared.meta;
@@ -9239,7 +9215,6 @@ var init_createServer = __esm({
9239
9215
  init_handleWsUpgrade();
9240
9216
  init_serverUtils();
9241
9217
  init_generateSchemaFiles();
9242
- init_copyResources();
9243
9218
  init_compileOnDemand();
9244
9219
  init_loadMiddlewares();
9245
9220
  DEFAULT_BODY_LIMIT = 10 * 1024 * 1024;
@@ -9419,7 +9394,6 @@ async function runTaskInWorker(options) {
9419
9394
  payload,
9420
9395
  taskCtx: {
9421
9396
  config: safeConfig(taskCtx.config),
9422
- resourcesDir: taskCtx.resourcesDir,
9423
9397
  job: taskCtx.job
9424
9398
  },
9425
9399
  registries: options.registries,
@@ -9578,7 +9552,6 @@ function createTaskQueue(deps) {
9578
9552
  const taskCtx = {
9579
9553
  signal: job.signal,
9580
9554
  config: deps.config,
9581
- resourcesDir: deps.resourcesDir,
9582
9555
  job: { id: job.id, name: job.name, attempt: job.attempt },
9583
9556
  registries: registriesView,
9584
9557
  log: createLogger(`task:${job.name}`, {
@@ -10297,7 +10270,6 @@ async function createAppBase(options) {
10297
10270
  config?.plugins,
10298
10271
  {
10299
10272
  rootDir,
10300
- resourcesDir,
10301
10273
  registries,
10302
10274
  routes: sorted,
10303
10275
  getRoutes: () => sorted,
@@ -10328,8 +10300,7 @@ async function createAppBase(options) {
10328
10300
  routes: sorted,
10329
10301
  server,
10330
10302
  registries,
10331
- tasks: taskQueue,
10332
- resourcesDir
10303
+ tasks: taskQueue
10333
10304
  });
10334
10305
  console.log("- onBoot hook executed");
10335
10306
  } catch (err) {
@@ -10364,8 +10335,7 @@ async function createAppBase(options) {
10364
10335
  routes: sorted,
10365
10336
  server,
10366
10337
  registries,
10367
- tasks: taskQueue,
10368
- resourcesDir
10338
+ tasks: taskQueue
10369
10339
  });
10370
10340
  console.log("- onReady hook executed");
10371
10341
  }
@@ -10389,8 +10359,7 @@ async function createAppBase(options) {
10389
10359
  routes: sorted,
10390
10360
  server,
10391
10361
  registries,
10392
- tasks: taskQueue,
10393
- resourcesDir
10362
+ tasks: taskQueue
10394
10363
  });
10395
10364
  }
10396
10365
  registries.tool.clear();