@torpor/build 0.4.12 → 0.4.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torpor/build",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "A framework for building sites and apps with Torpor",
5
5
  "type": "module",
6
6
  "exports": {
@@ -62,7 +62,13 @@ export async function load(ev: ServerEvent, template: string): Promise<Response>
62
62
  if (ev.request.method === "GET") {
63
63
  return handleResponse(await loadView(ev, url, handler, params, template));
64
64
  } else if (ev.request.method === "POST") {
65
- return handleResponse(await runAction(ev, url, handler, params, query, template), true);
65
+ // The server end point comes from the sibling /+page.server.ts, if applicable
66
+ const serverEndPoint: PageServerEndPoint | undefined =
67
+ handler.serverEndPoint && (await handler.serverEndPoint()).default;
68
+ return handleResponse(
69
+ await runAction(ev, url, handler, serverEndPoint, params, query, template),
70
+ true,
71
+ );
66
72
  }
67
73
  break;
68
74
  }
@@ -71,6 +77,13 @@ export async function load(ev: ServerEvent, template: string): Promise<Response>
71
77
  // It's a /+page.server.ts or /_layout.server.ts endpoint
72
78
  if (ev.request.method === "GET") {
73
79
  return await loadData(ev, url, handler, "load", params);
80
+ } else if (ev.request.method === "POST") {
81
+ const serverEndPoint: PageServerEndPoint | undefined =
82
+ handler.endPoint && (await handler.endPoint()).default;
83
+ return handleResponse(
84
+ await runAction(ev, url, handler, serverEndPoint, params, query, template),
85
+ true,
86
+ );
74
87
  }
75
88
  break;
76
89
  }
@@ -283,13 +296,12 @@ async function runAction(
283
296
  ev: ServerEvent,
284
297
  url: URL,
285
298
  handler: RouteHandler,
299
+ serverEndPoint: PageServerEndPoint | undefined,
286
300
  params: Record<string, string>,
287
301
  query: URLSearchParams,
288
302
  template: string,
289
303
  ) {
290
304
  const actionName = (Array.from(query.keys())[0] || "default").replace(/^\//, "");
291
- const serverEndPoint: PageServerEndPoint | undefined =
292
- handler.serverEndPoint && (await handler.serverEndPoint()).default;
293
305
  if (serverEndPoint?.actions) {
294
306
  const action = serverEndPoint.actions[actionName];
295
307
  if (action) {