diff --git a/server.js b/server.js deleted file mode 100644 index 531d971..0000000 --- a/server.js +++ /dev/null @@ -1,18 +0,0 @@ -const express = require("express"); -const path = require("path"); -const history = require("connect-history-api-fallback"); - -const publicPath = path.join(__dirname, "public"); - -app = express(); -app.use("/", express.static(publicPath)); -app.use(history({ index: "/" })); - -app.get("/", function (req, res) { - res.sendFile(`${publicPath}/index.html`); -}); - -const port = process.env.PORT || 5001; -console.log("Server runnning at port:", port); - -app.listen(port); diff --git a/server.ts b/server.ts new file mode 100644 index 0000000..34cc253 --- /dev/null +++ b/server.ts @@ -0,0 +1,25 @@ +import express, { Express, Request, Response } from "express"; + +import path from "path"; +const history = require("connect-history-api-fallback"); + +const publicPath = path.join(__dirname, "..", "public"); + +const app: Express = express(); + +app.get("/_healthz", (_, res) => { + res.status(200).send("ok"); +}); + +app.use("/", express.static(publicPath)); +app.use(history({ index: "/" })); + +app.get("/", (req: Request, res: Response) => { + console.log("trying to get:", req.path); + res.sendFile(`${publicPath}/index.html`); +}); + +const port = process.env.PORT || 5001; +console.log("Server runnning at port:", port); + +app.listen(port); diff --git a/tsconfig.server.json b/tsconfig.server.json new file mode 100644 index 0000000..592dd9b --- /dev/null +++ b/tsconfig.server.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "target": "esnext", + "outDir": "./lib", + "lib": ["es2017"], + "module": "commonjs", + "moduleResolution": "node", + "allowJs": true, + "alwaysStrict": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "noEmit": false, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noImplicitAny": true, + "resolveJsonModule": true, + "declaration": true, + "sourceMap": false, + "preserveConstEnums": true, + "skipLibCheck": true, + "removeComments": false, + "strict": true, + "typeRoots": ["./node_modules/@types"] + }, + "include": ["server.ts"] +}