diff --git a/package.json b/package.json index 25b30d4..a070453 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "license": "MIT", "private": true, "dependencies": { + "app-root-path": "^3.0.0", "express": "^4.17.1", "express-ws": "^4.0.0", "heroku-ssl-redirect": "^0.0.4", diff --git a/src/server.js b/src/server.js new file mode 100644 index 0000000..875c365 --- /dev/null +++ b/src/server.js @@ -0,0 +1,14 @@ +const appRoot = require("app-root-path"); +const express = require("express"); +const sslRedirect = require("heroku-ssl-redirect"); + +const app = express(); +const host = process.env.HOST || "localhost"; +const port = parseInt(process.env.PORT) || 6119; + +app.use(sslRedirect()); +app.use("/", express.static(appRoot + "/static")); + +app.listen(port, host, () => + console.log(`Listening on http://${host}:${port}`) +); diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..c0008f1 --- /dev/null +++ b/static/index.html @@ -0,0 +1,10 @@ + + + + + Fast Sandbox + + + Hello, world! + + diff --git a/yarn.lock b/yarn.lock index 2fe1220..5bc799a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,6 +10,11 @@ accepts@~1.3.7: mime-types "~2.1.24" negotiator "0.6.2" +app-root-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/app-root-path/-/app-root-path-3.0.0.tgz#210b6f43873227e18a4b810a032283311555d5ad" + integrity sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw== + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"