mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
update store test
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { Store } from 'svelte/store.js';
|
||||
import * as sapper from '@sapper/client';
|
||||
|
||||
window.start = () => sapper.start({
|
||||
target: document.querySelector('#sapper'),
|
||||
store: data => new Store(data)
|
||||
target: document.querySelector('#sapper')
|
||||
});
|
||||
|
||||
window.prefetchRoutes = () => sapper.prefetchRoutes();
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
<h1>{$title}</h1>
|
||||
<script>
|
||||
import * as sapper from '@sapper/client';
|
||||
const session = sapper.session();
|
||||
</script>
|
||||
|
||||
<h1>{$session.title}</h1>
|
||||
@@ -1,5 +1,4 @@
|
||||
import polka from 'polka';
|
||||
import { Store } from 'svelte/store.js';
|
||||
import * as sapper from '@sapper/server';
|
||||
|
||||
const { PORT } = process.env;
|
||||
@@ -12,11 +11,9 @@ polka()
|
||||
})
|
||||
.use(
|
||||
sapper.middleware({
|
||||
store: (req, res) => {
|
||||
return new Store({
|
||||
title: `${req.hello} ${res.locals.name}`
|
||||
});
|
||||
}
|
||||
session: (req, res) => ({
|
||||
title: `${req.hello} ${res.locals.name}`
|
||||
})
|
||||
})
|
||||
)
|
||||
.listen(PORT);
|
||||
|
||||
Reference in New Issue
Block a user