aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/index.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-10-28 00:14:01 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:58 +0300
commit40d411e516efee5531404725b45ab89d97172ce8 (patch)
treed675e93fc52ef50a40343219e1b992867964d3bf /vnext/server/index.js
parent2146a98bd98b7e275a0ee7bc7a243981b597f34c (diff)
Initial SSR
Diffstat (limited to 'vnext/server/index.js')
-rw-r--r--vnext/server/index.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/vnext/server/index.js b/vnext/server/index.js
new file mode 100644
index 00000000..2b696977
--- /dev/null
+++ b/vnext/server/index.js
@@ -0,0 +1,32 @@
+import express from 'express';
+
+// we'll talk about this in a minute:
+import serverRenderer from './middleware/renderer';
+
+const PORT = 3000;
+const path = require('path');
+
+// initialize the application and create the routes
+const app = express();
+const router = express.Router();
+
+router.use('^/$', serverRenderer);
+
+// other static resources should just be served as they are
+router.use(express.static(
+ path.resolve(__dirname, '..', 'dist'),
+ { maxAge: '30d' },
+));
+
+router.use('*', serverRenderer);
+
+app.use(router);
+
+// start the app
+app.listen(PORT, (error) => {
+ if (error) {
+ return console.log('something bad happened', error);
+ }
+
+ console.log('listening on ' + PORT + '...');
+});