Skip to content

Commit 87fad2c

Browse files
committed
Revert "add todo"
This reverts commit 858a238.
1 parent 99cb82e commit 87fad2c

File tree

15 files changed

+74
-137
lines changed

15 files changed

+74
-137
lines changed

apps/svelte.dev/content/docs/kit/10-getting-started/30-project-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Project structure
55

66
A typical SvelteKit project looks like this:
77

8-
```tree
8+
```bash
99
my-project/
1010
├ src/
1111
│ ├ lib/

apps/svelte.dev/content/docs/kit/20-core-concepts/30-form-actions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ Note that you need to `deserialize` the response before processing it further us
470470
If you have a `+server.js` alongside your `+page.server.js`, `fetch` requests will be routed there by default. To `POST` to an action in `+page.server.js` instead, use the custom `x-sveltekit-action` header:
471471
472472
```js
473-
// @errors: 2532 2304
474473
const response = await fetch(this.action, {
475474
method: 'POST',
476475
body: data,

apps/svelte.dev/content/docs/kit/25-build-and-deploy/40-adapter-node.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ Install with `npm i -D @sveltejs/adapter-node`, then add the adapter to your `sv
1111

1212
```js
1313
// @errors: 2307
14+
/// file: svelte.config.js
1415
import adapter from '@sveltejs/adapter-node';
1516

16-
/** @type {import('@sveltejs/kit').Config} */
17-
const config = {
17+
export default {
1818
kit: {
1919
adapter: adapter()
2020
}
2121
};
22-
23-
export default config;
2422
```
2523

2624
## Deploying
@@ -67,21 +65,21 @@ node +++--env-file=.env+++ build
6765

6866
By default, the server will accept connections on `0.0.0.0` using port 3000. These can be customised with the `PORT` and `HOST` environment variables:
6967

70-
```bash
68+
```
7169
HOST=127.0.0.1 PORT=4000 node build
7270
```
7371

7472
Alternatively, the server can be configured to accept connections on a specified socket path. When this is done using the `SOCKET_PATH` environment variable, the `HOST` and `PORT` environment variables will be disregarded.
7573

76-
```bash
74+
```
7775
SOCKET_PATH=/tmp/socket node build
7876
```
7977

8078
### `ORIGIN`, `PROTOCOL_HEADER`, `HOST_HEADER`, and `PORT_HEADER`
8179

8280
HTTP doesn't give SvelteKit a reliable way to know the URL that is currently being requested. The simplest way to tell SvelteKit where the app is being served is to set the `ORIGIN` environment variable:
8381

84-
```bash
82+
```
8583
ORIGIN=https://my.site node build
8684
8785
# or e.g. for local previewing and testing
@@ -90,7 +88,7 @@ ORIGIN=http://localhost:3000 node build
9088

9189
With this, a request for the `/stuff` pathname will correctly resolve to `https://my.site/stuff`. Alternatively, you can specify headers that tell SvelteKit about the request protocol and host, from which it can construct the origin URL:
9290

93-
```bash
91+
```
9492
PROTOCOL_HEADER=x-forwarded-proto HOST_HEADER=x-forwarded-host node build
9593
```
9694

@@ -106,7 +104,7 @@ If `adapter-node` can't correctly determine the URL of your deployment, you may
106104

107105
The [`RequestEvent`](@sveltejs-kit#RequestEvent) object passed to hooks and endpoints includes an `event.getClientAddress()` function that returns the client's IP address. By default this is the connecting `remoteAddress`. If your server is behind one or more proxies (such as a load balancer), this value will contain the innermost proxy's IP address rather than the client's, so we need to specify an `ADDRESS_HEADER` to read the address from:
108106

109-
```bash
107+
```
110108
ADDRESS_HEADER=True-Client-IP node build
111109
```
112110

@@ -149,8 +147,7 @@ The adapter can be configured with various options:
149147
/// file: svelte.config.js
150148
import adapter from '@sveltejs/adapter-node';
151149

152-
/** @type {import('@sveltejs/kit').Config} */
153-
const config = {
150+
export default {
154151
kit: {
155152
adapter: adapter({
156153
// default options are shown
@@ -160,8 +157,6 @@ const config = {
160157
})
161158
}
162159
};
163-
164-
export default config;
165160
```
166161

167162
### out
@@ -180,7 +175,7 @@ If you need to change the name of the environment variables used to configure th
180175
envPrefix: 'MY_CUSTOM_';
181176
```
182177

183-
```bash
178+
```sh
184179
MY_CUSTOM_HOST=127.0.0.1 \
185180
MY_CUSTOM_PORT=4000 \
186181
MY_CUSTOM_ORIGIN=https://my.site \

apps/svelte.dev/content/docs/kit/25-build-and-deploy/50-adapter-static.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ This will prerender your entire site as a collection of static files. If you'd l
1212
Install with `npm i -D @sveltejs/adapter-static`, then add the adapter to your `svelte.config.js`:
1313

1414
```js
15+
// @errors: 2307
1516
/// file: svelte.config.js
1617
import adapter from '@sveltejs/adapter-static';
1718

18-
/** @type {import('@sveltejs/kit').Config} */
19-
const config = {
19+
export default {
2020
kit: {
2121
adapter: adapter({
2222
// default options are shown. On some platforms
@@ -29,8 +29,6 @@ const config = {
2929
})
3030
}
3131
};
32-
33-
export default config;
3432
```
3533

3634
...and add the [`prerender`](page-options#prerender) option to your root layout:
@@ -52,17 +50,13 @@ Some platforms have zero-config support (more to come in future):
5250
On these platforms, you should omit the adapter options so that `adapter-static` can provide the optimal configuration:
5351

5452
```js
53+
// @errors: 2304
5554
/// file: svelte.config.js
56-
import adapter from '@sveltejs/adapter-static';
57-
58-
/** @type {import('@sveltejs/kit').Config} */
59-
const config = {
55+
export default {
6056
kit: {
6157
adapter: adapter(---{...}---)
6258
}
6359
};
64-
65-
export default config;
6660
```
6761

6862
## Options
@@ -96,7 +90,7 @@ You'll also want to generate a fallback `404.html` page to replace the default 4
9690
A config for GitHub Pages might look like the following:
9791

9892
```js
99-
// @errors: 2322
93+
// @errors: 2307 2322
10094
/// file: svelte.config.js
10195
import adapter from '@sveltejs/adapter-static';
10296

apps/svelte.dev/content/docs/kit/25-build-and-deploy/55-single-page-apps.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,17 @@ If you don't have any server-side logic (i.e. `+page.server.js`, `+layout.server
1919
Install with `npm i -D @sveltejs/adapter-static`, then add the adapter to your `svelte.config.js` with the following options:
2020

2121
```js
22+
// @errors: 2307
2223
/// file: svelte.config.js
2324
import adapter from '@sveltejs/adapter-static';
2425

25-
/** @type {import('@sveltejs/kit').Config} */
26-
const config = {
26+
export default {
2727
kit: {
2828
adapter: adapter({
2929
fallback: '200.html' // may differ from host to host
3030
})
3131
}
3232
};
33-
34-
export default config;
3533
```
3634

3735
The `fallback` page is an HTML page created by SvelteKit from your page template (e.g. `app.html`) that loads your app and navigates to the correct route. For example [Surge](https://surge.sh/help/adding-a-200-page-for-client-side-routing), a static web host, lets you add a `200.html` file that will handle any requests that don't correspond to static assets or prerendered pages.

apps/svelte.dev/content/docs/kit/25-build-and-deploy/60-adapter-cloudflare.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Install with `npm i -D @sveltejs/adapter-cloudflare`, then add the adapter to yo
2121
/// file: svelte.config.js
2222
import adapter from '@sveltejs/adapter-cloudflare';
2323

24-
/** @type {import('@sveltejs/kit').Config} */
25-
const config = {
24+
export default {
2625
kit: {
2726
adapter: adapter({
2827
// See below for an explanation of these options
@@ -40,8 +39,6 @@ const config = {
4039
})
4140
}
4241
};
43-
44-
export default config;
4542
```
4643

4744
## Options
@@ -129,25 +126,9 @@ Functions contained in the [`/functions` directory](https://developers.cloudflar
129126
The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object contains your project's [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/), which consist of KV/DO namespaces, etc. It is passed to SvelteKit via the `platform` property, along with [`context`](https://developers.cloudflare.com/workers/runtime-apis/context/), [`caches`](https://developers.cloudflare.com/workers/runtime-apis/cache/), and [`cf`](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties), meaning that you can access it in hooks and endpoints:
130127

131128
```js
132-
// @filename: ambient.d.ts
133-
import { DurableObjectNamespace } from '@cloudflare/workers-types';
134-
135-
declare global {
136-
namespace App {
137-
interface Platform {
138-
env: {
139-
YOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;
140-
};
141-
}
142-
}
143-
}
144-
// @filename: +server.js
145-
// ---cut---
146-
// @errors: 2355 2322
147-
/// file: +server.js
148-
/** @type {import('./$types').RequestHandler} */
129+
// @errors: 7031
149130
export async function POST({ request, platform }) {
150-
const x = platform?.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');
131+
const x = platform.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');
151132
}
152133
```
153134

@@ -162,7 +143,7 @@ To make these types available to your app, install [`@cloudflare/workers-types`]
162143
declare global {
163144
namespace App {
164145
interface Platform {
165-
+++ env: {
146+
+++ env?: {
166147
YOUR_KV_NAMESPACE: KVNamespace;
167148
YOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;
168149
};+++
@@ -213,19 +194,15 @@ Cloudflare no longer recommends using [Workers Sites](https://developers.cloudfl
213194
### svelte.config.js
214195

215196
```js
216-
// @errors: 2307
217197
/// file: svelte.config.js
218198
---import adapter from '@sveltejs/adapter-cloudflare-workers';---
219199
+++import adapter from '@sveltejs/adapter-cloudflare';+++
220200

221-
/** @type {import('@sveltejs/kit').Config} */
222-
const config = {
201+
export default {
223202
kit: {
224203
adapter: adapter()
225204
}
226205
};
227-
228-
export default config;
229206
```
230207

231208
### wrangler.toml

apps/svelte.dev/content/docs/kit/25-build-and-deploy/70-adapter-cloudflare-workers.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ Install with `npm i -D @sveltejs/adapter-cloudflare-workers`, then add the adapt
1616
/// file: svelte.config.js
1717
import adapter from '@sveltejs/adapter-cloudflare-workers';
1818

19-
/** @type {import('@sveltejs/kit').Config} */
20-
const config = {
19+
export default {
2120
kit: {
2221
adapter: adapter({
2322
// see below for options that can be set here
2423
})
2524
}
2625
};
27-
28-
export default config;
2926
```
3027

3128
## Options
@@ -68,14 +65,14 @@ https://dash.cloudflare.com/<your-account-id>/home
6865
6966
You will need to install [Wrangler](https://developers.cloudflare.com/workers/wrangler/install-and-update/) and log in, if you haven't already:
7067

71-
```bash
68+
```sh
7269
npm i -D wrangler
7370
wrangler login
7471
```
7572

7673
Then, you can build your app and deploy it:
7774

78-
```bash
75+
```sh
7976
wrangler deploy
8077
```
8178

@@ -84,25 +81,9 @@ wrangler deploy
8481
The [`env`](https://developers.cloudflare.com/workers/runtime-apis/fetch-event#parameters) object contains your project's [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/), which consist of KV/DO namespaces, etc. It is passed to SvelteKit via the `platform` property, along with [`context`](https://developers.cloudflare.com/workers/runtime-apis/context/), [`caches`](https://developers.cloudflare.com/workers/runtime-apis/cache/), and [`cf`](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties), meaning that you can access it in hooks and endpoints:
8582

8683
```js
87-
// @filename: ambient.d.ts
88-
import { DurableObjectNamespace } from '@cloudflare/workers-types';
89-
90-
declare global {
91-
namespace App {
92-
interface Platform {
93-
env: {
94-
YOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace;
95-
};
96-
}
97-
}
98-
}
99-
// @filename: +server.js
100-
// ---cut---
101-
// @errors: 2355 2322
102-
/// file: +server.js
103-
/** @type {import('./$types').RequestHandler} */
84+
// @errors: 7031
10485
export async function POST({ request, platform }) {
105-
const x = platform?.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');
86+
const x = platform.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');
10687
}
10788
```
10889

apps/svelte.dev/content/docs/kit/25-build-and-deploy/80-adapter-netlify.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ This adapter will be installed by default when you use [`adapter-auto`](adapter-
1212
Install with `npm i -D @sveltejs/adapter-netlify`, then add the adapter to your `svelte.config.js`:
1313

1414
```js
15+
// @errors: 2307
1516
/// file: svelte.config.js
1617
import adapter from '@sveltejs/adapter-netlify';
1718

18-
/** @type {import('@sveltejs/kit').Config} */
19-
const config = {
19+
export default {
2020
kit: {
2121
// default options are shown
2222
adapter: adapter({
@@ -31,8 +31,6 @@ const config = {
3131
})
3232
}
3333
};
34-
35-
export default config;
3634
```
3735

3836
Then, make sure you have a [netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration) file in the project root. This will determine where to write static assets based on the `build.publish` settings, as per this sample configuration:
@@ -54,11 +52,11 @@ New projects will use the current Node LTS version by default. However, if you'r
5452
SvelteKit supports [Netlify Edge Functions](https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/). If you pass the option `edge: true` to the `adapter` function, server-side rendering will happen in a Deno-based edge function that's deployed close to the site visitor. If set to `false` (the default), the site will deploy to Node-based Netlify Functions.
5553

5654
```js
55+
// @errors: 2307
5756
/// file: svelte.config.js
5857
import adapter from '@sveltejs/adapter-netlify';
5958

60-
/** @type {import('@sveltejs/kit').Config} */
61-
const config = {
59+
export default {
6260
kit: {
6361
adapter: adapter({
6462
// will create a Netlify Edge Function using Deno-based
@@ -67,8 +65,6 @@ const config = {
6765
})
6866
}
6967
};
70-
71-
export default config;
7268
```
7369

7470
## Netlify alternatives to SvelteKit functionality
@@ -97,14 +93,10 @@ During compilation, redirect rules are automatically appended to your `_redirect
9793
With this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and `+page.server` or `+layout.server` endpoints. These are [serverless functions](https://docs.netlify.com/functions/overview/) when the `edge` property is `false` in the adapter config or [edge functions](https://docs.netlify.com/edge-functions/overview/#app) when it is `true`.
9894

9995
```js
100-
// @filename: ambient.d.ts
101-
/// <reference types="@sveltejs/adapter-netlify" />
102-
// @filename: +page.server.js
103-
// ---cut---
96+
// @errors: 2705 7006
10497
/// file: +page.server.js
105-
/** @type {import('./$types').PageServerLoad} */
10698
export const load = async (event) => {
107-
const context = event.platform?.context;
99+
const context = event.platform.context;
108100
console.log(context); // shows up in your functions log in the Netlify app
109101
};
110102
```

0 commit comments

Comments
 (0)