@sveltejs/kit 1.2.9 → 1.2.10

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": "@sveltejs/kit",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -69,23 +69,23 @@ export async function handle_action_json_request(event, options, server) {
69
69
  });
70
70
  }
71
71
  } catch (e) {
72
- const error = normalize_error(e);
72
+ const err = normalize_error(e);
73
73
 
74
- if (error instanceof Redirect) {
74
+ if (err instanceof Redirect) {
75
75
  return action_json({
76
76
  type: 'redirect',
77
- status: error.status,
78
- location: error.location
77
+ status: err.status,
78
+ location: err.location
79
79
  });
80
80
  }
81
81
 
82
82
  return action_json(
83
83
  {
84
84
  type: 'error',
85
- error: await handle_error_and_jsonify(event, options, check_incorrect_fail_use(error))
85
+ error: await handle_error_and_jsonify(event, options, check_incorrect_fail_use(err))
86
86
  },
87
87
  {
88
- status: error instanceof HttpError ? error.status : 500
88
+ status: err instanceof HttpError ? err.status : 500
89
89
  }
90
90
  );
91
91
  }
@@ -110,19 +110,18 @@ function action_json(data, init) {
110
110
 
111
111
  /**
112
112
  * @param {import('types').RequestEvent} event
113
- * @param {import('types').SSRNode} leaf_node
114
113
  */
115
- export function is_action_request(event, leaf_node) {
116
- return leaf_node.server && event.request.method !== 'GET' && event.request.method !== 'HEAD';
114
+ export function is_action_request(event) {
115
+ return event.request.method === 'POST';
117
116
  }
118
117
 
119
118
  /**
120
119
  * @param {import('types').RequestEvent} event
121
- * @param {import('types').SSRNode['server']} server
120
+ * @param {import('types').SSRNode['server'] | undefined} server
122
121
  * @returns {Promise<import('types').ActionResult>}
123
122
  */
124
123
  export async function handle_action_request(event, server) {
125
- const actions = server.actions;
124
+ const actions = server?.actions;
126
125
 
127
126
  if (!actions) {
128
127
  // TODO should this be a different error altogether?
@@ -161,19 +160,19 @@ export async function handle_action_request(event, server) {
161
160
  };
162
161
  }
163
162
  } catch (e) {
164
- const error = normalize_error(e);
163
+ const err = normalize_error(e);
165
164
 
166
- if (error instanceof Redirect) {
165
+ if (err instanceof Redirect) {
167
166
  return {
168
167
  type: 'redirect',
169
- status: error.status,
170
- location: error.location
168
+ status: err.status,
169
+ location: err.location
171
170
  };
172
171
  }
173
172
 
174
173
  return {
175
174
  type: 'error',
176
- error: check_incorrect_fail_use(error)
175
+ error: check_incorrect_fail_use(err)
177
176
  };
178
177
  }
179
178
  }
@@ -59,7 +59,7 @@ export async function render_page(event, route, page, options, manifest, state,
59
59
  /** @type {import('types').ActionResult | undefined} */
60
60
  let action_result = undefined;
61
61
 
62
- if (is_action_request(event, leaf_node)) {
62
+ if (is_action_request(event)) {
63
63
  // for action requests, first call handler in +page.server.js
64
64
  // (this also determines status code)
65
65
  action_result = await handle_action_request(event, leaf_node.server);
@@ -85,7 +85,7 @@ export async function render_page(event, route, page, options, manifest, state,
85
85
 
86
86
  if (should_prerender) {
87
87
  const mod = leaf_node.server;
88
- if (mod && mod.actions) {
88
+ if (mod?.actions) {
89
89
  throw new Error('Cannot prerender pages with actions');
90
90
  }
91
91
  } else if (state.prerendering) {