@niledatabase/server 4.2.0-alpha.2 → 4.2.0-alpha.3

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/index.d.mts CHANGED
@@ -315,9 +315,18 @@ declare class Api {
315
315
  response: void | Response;
316
316
  nile: Server;
317
317
  }>;
318
- POST: (req: Request) => Promise<void | Response>;
319
- DELETE: (req: Request) => Promise<void | Response>;
320
- PUT: (req: Request) => Promise<void | Response>;
318
+ POST: (req: Request) => Promise<{
319
+ response: void | Response;
320
+ nile: Server;
321
+ }>;
322
+ DELETE: (req: Request) => Promise<{
323
+ response: void | Response;
324
+ nile: Server;
325
+ }>;
326
+ PUT: (req: Request) => Promise<{
327
+ response: void | Response;
328
+ nile: Server;
329
+ }>;
321
330
  };
322
331
  paths: {
323
332
  get: string[];
package/dist/index.d.ts CHANGED
@@ -315,9 +315,18 @@ declare class Api {
315
315
  response: void | Response;
316
316
  nile: Server;
317
317
  }>;
318
- POST: (req: Request) => Promise<void | Response>;
319
- DELETE: (req: Request) => Promise<void | Response>;
320
- PUT: (req: Request) => Promise<void | Response>;
318
+ POST: (req: Request) => Promise<{
319
+ response: void | Response;
320
+ nile: Server;
321
+ }>;
322
+ DELETE: (req: Request) => Promise<{
323
+ response: void | Response;
324
+ nile: Server;
325
+ }>;
326
+ PUT: (req: Request) => Promise<{
327
+ response: void | Response;
328
+ nile: Server;
329
+ }>;
321
330
  };
322
331
  paths: {
323
332
  get: string[];
package/dist/index.js CHANGED
@@ -2438,24 +2438,38 @@ function handlersWithContext(configRoutes, config) {
2438
2438
  const updatedConfig = updateConfig(response, config);
2439
2439
  return { response, nile: new Server(updatedConfig) };
2440
2440
  },
2441
- POST: POST5,
2442
- DELETE: DELETE3,
2443
- PUT: PUT4
2441
+ POST: async (req) => {
2442
+ const response = await POST5(req);
2443
+ const updatedConfig = updateConfig(response, config);
2444
+ return { response, nile: new Server(updatedConfig) };
2445
+ },
2446
+ DELETE: async (req) => {
2447
+ const response = await DELETE3(req);
2448
+ const updatedConfig = updateConfig(response, config);
2449
+ return { response, nile: new Server(updatedConfig) };
2450
+ },
2451
+ PUT: async (req) => {
2452
+ const response = await PUT4(req);
2453
+ const updatedConfig = updateConfig(response, config);
2454
+ return { response, nile: new Server(updatedConfig) };
2455
+ }
2444
2456
  };
2445
2457
  }
2446
2458
  function updateConfig(response, config) {
2447
2459
  let origin = "http://localhost:3000";
2448
2460
  let headers = null;
2449
- if (response.status === 302) {
2461
+ if (response?.status === 302) {
2450
2462
  const location = response.headers.get("location");
2451
2463
  if (location) {
2452
2464
  origin = location;
2453
2465
  }
2454
2466
  }
2455
2467
  const setCookies = [];
2456
- for (const [key12, value] of response.headers) {
2457
- if (key12.toLowerCase() === "set-cookie") {
2458
- setCookies.push(value);
2468
+ if (response?.headers) {
2469
+ for (const [key12, value] of response.headers) {
2470
+ if (key12.toLowerCase() === "set-cookie") {
2471
+ setCookies.push(value);
2472
+ }
2459
2473
  }
2460
2474
  }
2461
2475
  if (setCookies.length > 0) {