Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const path = require('path');
const express = require('express');
const { createHistory } = require('svelte-routing');
const history = createHistory('memory');
const server = express();
const app = require('./dist/ssr/bundle.js'); // require component
server.use(express.static(path.join(__dirname, 'dist')));
server.get('/cart/*', function(req, res) {
history.replace(req.url);
res.write(`
<div class="grid grid--reverse" id="cart">${app.render()}</div>
`);
res.end();
});
const listenAndCreateHistory = listen => {
const history = createBrowserHistory()
// Listen for changes to the current location.
history.listen(() => {
if (listen && typeof listen === 'function') {
setTimeout(listen())
}
})
setTimeout(history.listen(), 1000)
}
import App from './CartApp.html';
import { createHistory } from 'svelte-routing';
createHistory('browser');
const app = new App({
target: document.getElementById('cart'),
hydrate: true
});