Converted server to ts w/ its own tsconfig
This commit is contained in:
18
server.js
18
server.js
@@ -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);
|
|
||||||
25
server.ts
Normal file
25
server.ts
Normal file
@@ -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);
|
||||||
30
tsconfig.server.json
Normal file
30
tsconfig.server.json
Normal file
@@ -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"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user