-
Your Settings
-
+
+
+
-
+
-
\ No newline at end of file
+
diff --git a/examples/realworld.svelte.dev/src/routes/tags.json.js b/examples/realworld.svelte.dev/src/routes/tags.json.js
new file mode 100644
index 000000000000..6a4f8d345ced
--- /dev/null
+++ b/examples/realworld.svelte.dev/src/routes/tags.json.js
@@ -0,0 +1,19 @@
+import * as api from '$lib/api';
+
+export async function get() {
+ const { tags } = await api.get('tags');
+
+ // The Conduit API doesn't set a cache-control header on
+ // this resource, but it doesn't change frequently enough
+ // that it's worth revalidating on every request. Instead,
+ // we cache it at the CDN level (`public`) for five
+ // minutes (`max-age=300`) to improve performance
+ return {
+ headers: {
+ 'cache-control': 'public, max-age=300'
+ },
+ body: {
+ tags: tags.filter((tag) => /^[a-z]+$/i.test(tag))
+ }
+ };
+}
diff --git a/examples/realworld.svelte.dev/src/setup/index.js b/examples/realworld.svelte.dev/src/setup/index.js
index ee838c6ba5dc..b75253e0da69 100644
--- a/examples/realworld.svelte.dev/src/setup/index.js
+++ b/examples/realworld.svelte.dev/src/setup/index.js
@@ -1,12 +1,24 @@
+import * as cookie from 'cookie';
+
export function prepare({ headers }) {
- // TODO
+ const cookies = cookie.parse(headers.cookie || '');
+ const jwt = cookies.jwt && Buffer.from(cookies.jwt, 'base64').toString('utf-8');
+
return {
- context: {},
+ context: {
+ user: jwt ? JSON.parse(jwt) : null
+ },
headers: {}
};
}
export function getSession({ context }) {
- // TODO
- return context;
+ return {
+ user: context.user && {
+ username: context.user.username,
+ email: context.user.email,
+ image: context.user.image,
+ bio: context.user.bio
+ }
+ };
}
diff --git a/examples/realworld.svelte.dev/static/logo-256.png b/examples/realworld.svelte.dev/static/logo-256.png
new file mode 100644
index 000000000000..e9bdc637287a
Binary files /dev/null and b/examples/realworld.svelte.dev/static/logo-256.png differ
diff --git a/examples/realworld.svelte.dev/static/manifest.json b/examples/realworld.svelte.dev/static/manifest.json
index fc5de0b53ff6..08d8d61800d2 100644
--- a/examples/realworld.svelte.dev/static/manifest.json
+++ b/examples/realworld.svelte.dev/static/manifest.json
@@ -1,19 +1,14 @@
{
"background_color": "#ffffff",
- "theme_color": "#aa1e1e",
+ "theme_color": "#5cb85c",
"name": "Svelte RealWorld",
"short_name": "RealWorld",
"display": "minimal-ui",
"start_url": "/",
"icons": [
{
- "src": "svelte-logo-192.png",
- "sizes": "192x192",
- "type": "image/png"
- },
- {
- "src": "svelte-logo-512.png",
- "sizes": "512x512",
+ "src": "logo-256.png",
+ "sizes": "256x256",
"type": "image/png"
}
]
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e4d991599ebe..bb6532db7db2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -41,6 +41,7 @@ importers:
svelte: ^3.35.0
examples/realworld.svelte.dev:
dependencies:
+ cookie: 0.4.1
node-fetch: 2.6.1
devDependencies:
'@sveltejs/adapter-node': link:../../packages/adapter-node
@@ -50,6 +51,7 @@ importers:
specifiers:
'@sveltejs/adapter-node': workspace:*
'@sveltejs/kit': workspace:*
+ cookie: ^0.4.1
marked: ^2.0.1
node-fetch: ^2.6.1
svelte: ^3.35.0
@@ -1181,6 +1183,12 @@ packages:
node: '>=0.10.0'
resolution:
integrity: sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=
+ /cookie/0.4.1:
+ dev: false
+ engines:
+ node: '>= 0.6'
+ resolution:
+ integrity: sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==
/cross-spawn/5.1.0:
dependencies:
lru-cache: 4.1.5