diff --git a/server/lib/status-error.js b/server/lib/status-error.js index 873cb0c..bac4b11 100644 --- a/server/lib/status-error.js +++ b/server/lib/status-error.js @@ -3,8 +3,9 @@ var http = require('http'); /* Create an error as per http://bluebirdjs.com/docs/api/catch.html */ -function StatusError(status, message) { - if (!message) { +function StatusError(status, inputMessage) { + let message = inputMessage; + if (!inputMessage) { message = http.STATUS_CODES[status] || http.STATUS_CODES['500']; } diff --git a/server/start-dev.js b/server/start-dev.js index 91b62b8..fe4710b 100644 --- a/server/start-dev.js +++ b/server/start-dev.js @@ -6,10 +6,14 @@ const mergeOptions = require('merge-options'); const viteConfig = require('../vite.config'); -// See https://github.com/remy/nodemon/blob/main/doc/requireable.md +// Listen for any changes to files and restart the Node.js server process +// +// For API docs, see +// https://github.com/remy/nodemon/blob/main/doc/requireable.md nodemon({ script: path.join(__dirname, './server.js'), ext: 'js json', + ignore: [path.join(__dirname, '../dist/*')], }); nodemon @@ -24,10 +28,11 @@ nodemon console.log('App restarted due to: ', files); }); -// Build the client-side bundle +// Build the client-side JavaScript bundle when we see any changes build( mergeOptions(viteConfig, { build: { + // Rebuild when we see changes watch: true, }, }) diff --git a/shared/.eslintrc.json b/shared/.eslintrc.json new file mode 100644 index 0000000..e5a34ae --- /dev/null +++ b/shared/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "env": { + "browser": true + } +} diff --git a/shared/ArchiveView.js b/shared/ArchiveView.js index 333753d..a7d53fc 100644 --- a/shared/ArchiveView.js +++ b/shared/ArchiveView.js @@ -1,3 +1,5 @@ +'use strict'; + const { TemplateView, RoomView, RightPanelView } = require('hydrogen-view-sdk'); class ArchiveView extends TemplateView { diff --git a/shared/hydrogen-vm-render-script.js b/shared/hydrogen-vm-render-script.js index f39f48a..8c65622 100644 --- a/shared/hydrogen-vm-render-script.js +++ b/shared/hydrogen-vm-render-script.js @@ -1,3 +1,5 @@ +'use strict'; + const assert = require('matrix-public-archive-shared/lib/assert'); const { Platform, @@ -223,4 +225,7 @@ async function mountHydrogen() { app.replaceChildren(view.mount()); } +// N.B.: When we run this in a `vm`, it will return the last statement. It's +// important to leave this as the last statement so we can await the promise it +// returns and signal that all of the async tasks completed. mountHydrogen(); diff --git a/vite.config.js b/vite.config.js index a82cf44..467f942 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,4 +1,6 @@ // vite.config.js +'use strict'; + const path = require('path'); const { defineConfig } = require('vite');