mirror of
https://github.com/coollabsio/coolify-examples.git
synced 2026-02-20 06:18:57 +00:00
This PR includes Vue examples, in particular: - Vue Spa - Vue Spa + Router - Vue using Sever Side Rendering with Express.js. Also updated the general Readme.
39 lines
851 B
JavaScript
39 lines
851 B
JavaScript
import express from 'express';
|
|
import { renderToString } from 'vue/server-renderer';
|
|
import { createApp } from './app.js';
|
|
|
|
const server = express();
|
|
server.use(express.static('public'))
|
|
|
|
server.get('/', (req, res) => {
|
|
const app = createApp();
|
|
|
|
renderToString(app).then((html) => {
|
|
res.send(`
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Vue SSR Example</title>
|
|
<script type="importmap">
|
|
{
|
|
"imports": {
|
|
"vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"
|
|
}
|
|
}
|
|
</script>
|
|
<script type="module" src="./client.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="app">${html}</div>
|
|
</body>
|
|
</html>
|
|
`);
|
|
});
|
|
});
|
|
|
|
server.use(express.static('.'));
|
|
|
|
server.listen(3000, () => {
|
|
console.log('Server listening on port 3000');
|
|
});
|