@faapi/faapi 1.4.0 → 1.5.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
@@ -5994,7 +5994,7 @@ var init_loadPlugins = __esm({
5994
5994
  // src/cli/createAppCore.ts
5995
5995
  import fs13 from "fs";
5996
5996
  import path15 from "path";
5997
- import { PassThrough } from "stream";
5997
+ import { PassThrough, Readable as Readable4 } from "stream";
5998
5998
  function isFaapiConfigKey(key) {
5999
5999
  return FAAPI_CONFIG_KEYS.has(key);
6000
6000
  }
@@ -6139,11 +6139,7 @@ async function createAppBase(options) {
6139
6139
  reject(new Error("No request handler found"));
6140
6140
  return;
6141
6141
  }
6142
- const mockReq = new PassThrough({
6143
- read() {
6144
- this.push(null);
6145
- }
6146
- });
6142
+ const mockReq = Readable4.from(body !== void 0 ? [Buffer.from(JSON.stringify(body))] : []);
6147
6143
  mockReq.method = method;
6148
6144
  mockReq.url = `${reqPath}${queryStr}`;
6149
6145
  mockReq.headers = {
@@ -6152,9 +6148,6 @@ async function createAppBase(options) {
6152
6148
  "content-type": body !== void 0 ? "application/json" : void 0
6153
6149
  };
6154
6150
  mockReq.socket = { remoteAddress: "127.0.0.1" };
6155
- if (body !== void 0) {
6156
- mockReq.push(JSON.stringify(body));
6157
- }
6158
6151
  handler(
6159
6152
  mockReq,
6160
6153
  mockRes
@@ -6176,17 +6169,20 @@ async function createAppBase(options) {
6176
6169
  }
6177
6170
  if (!server.listening) {
6178
6171
  app.server = null;
6172
+ if (currentApp === app) currentApp = null;
6179
6173
  return;
6180
6174
  }
6181
6175
  return new Promise((resolve3) => {
6182
6176
  server.close((err) => {
6183
6177
  if (err) console.error("Error closing server:", err);
6184
6178
  app.server = null;
6179
+ if (currentApp === app) currentApp = null;
6185
6180
  resolve3();
6186
6181
  });
6187
6182
  });
6188
6183
  }
6189
6184
  };
6185
+ currentApp = app;
6190
6186
  const ctx = {
6191
6187
  rootDir,
6192
6188
  dist,
@@ -6205,7 +6201,7 @@ async function createAppBase(options) {
6205
6201
  };
6206
6202
  return { app, ctx };
6207
6203
  }
6208
- var DEFAULT_DIST, DEFAULT_PORT, ROUTES_FILE, PATTERNS, FAAPI_CONFIG_KEYS;
6204
+ var DEFAULT_DIST, DEFAULT_PORT, ROUTES_FILE, PATTERNS, currentApp, FAAPI_CONFIG_KEYS;
6209
6205
  var init_createAppCore = __esm({
6210
6206
  "src/cli/createAppCore.ts"() {
6211
6207
  "use strict";
@@ -6221,6 +6217,7 @@ var init_createAppCore = __esm({
6221
6217
  DEFAULT_PORT = 3e3;
6222
6218
  ROUTES_FILE = "faapi-routes.js";
6223
6219
  PATTERNS = ["src/api/**/*.ts"];
6220
+ currentApp = null;
6224
6221
  FAAPI_CONFIG_KEYS = /* @__PURE__ */ new Set([
6225
6222
  "cors",
6226
6223
  "lifecycle",