From a03f945dfc830ed458909cd126c14ad2a7019f6f Mon Sep 17 00:00:00 2001 From: Jacob Bowdoin Date: Fri, 14 Feb 2020 08:22:39 -0800 Subject: [PATCH 1/2] Give example of passing a session option I was looking for an example of how to do and found such on https://github.com/sveltejs/sapper/issues/961#issuecomment-546756518. It would be helpful to have this in the Sapper docs. --- site/content/docs/04-preloading.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/site/content/docs/04-preloading.md b/site/content/docs/04-preloading.md index bdbd70a6f..21c1e4b56 100644 --- a/site/content/docs/04-preloading.md +++ b/site/content/docs/04-preloading.md @@ -32,7 +32,13 @@ So if the example above was `src/routes/blog/[slug].svelte` and the URL was `/bl * `page.query.foo === 'bar'` * `page.query.baz === true` -`session` is generated on the server by the `session` option passed to `sapper.middleware` (TODO this needs further documentation. Perhaps a server API section?) +`session` is generated on the server by the `session` option passed to `sapper.middleware`. For example: +`sapper.middleware({ + session: (req, res) => ({ + user: req.user + }) +})` +(TODO this needs further documentation. Perhaps a server API section?) ### Return value From dddd0d2d04d35611fff20e4993c17d9f4dc0ed47 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 25 Feb 2020 21:22:53 -0500 Subject: [PATCH 2/2] tweak --- site/content/docs/04-preloading.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/site/content/docs/04-preloading.md b/site/content/docs/04-preloading.md index 21c1e4b56..2dd5f0d89 100644 --- a/site/content/docs/04-preloading.md +++ b/site/content/docs/04-preloading.md @@ -33,12 +33,14 @@ So if the example above was `src/routes/blog/[slug].svelte` and the URL was `/bl * `page.query.baz === true` `session` is generated on the server by the `session` option passed to `sapper.middleware`. For example: -`sapper.middleware({ + +```js +sapper.middleware({ session: (req, res) => ({ user: req.user }) -})` -(TODO this needs further documentation. Perhaps a server API section?) +}) +``` ### Return value