Forráskód Böngészése

Display a basic page.

Lee Morgan 1 éve
szülő
commit
2a80ab25f1
4 módosított fájl, 23 hozzáadás és 2 törlés
  1. 1 1
      .gitignore
  2. 7 1
      app.js
  3. 5 0
      routes/other.js
  4. 10 0
      views/index.html

+ 1 - 1
.gitignore

@@ -1,4 +1,4 @@
 node_modules/
-build/
+views/build/
 *.swp
 *.swo

+ 7 - 1
app.js

@@ -6,15 +6,18 @@ import cookieParser from "cookie-parser";
 
 import {catchError} from "./HttpError.js";
 
-const allowedOrigin = process.env.NODE_ENV === "production" ? "https://workout.leemorgan.dev" : "http://localhost:8000";
+import otherRoutes from "./routes/other.js";
+
 let mongoString = "mongodb://127.0.0.1/workout";
 if(process.env.COOKIE_SECRET){
     mongoString = `mongodb://workout:${process.env.MONGODB_PASS}@127.0.0.1:27017/workout?authSource=admin`;
 }
 
 mongoose.connect(mongoString);
+global.cwd = import.meta.dirname;
 
 const app = express();
+
 app.use(cookieParser(process.env.COOKIE_SECRET));
 app.use(compression());
 app.use(cors({
@@ -22,6 +25,9 @@ app.use(cors({
     credentials: true
 }));
 app.use(express.json());
+
+otherRoutes(app);
+
 app.use(catchError);
 
 if(process.env.NODE_ENV !== "production"){

+ 5 - 0
routes/other.js

@@ -0,0 +1,5 @@
+export default (app)=>{
+    app.get("/", (req, res)=>res.sendFile(`${global.cwd}/views/index.html`));
+    app.get("/index.js", (req, res)=>res.sendFile(`${global.cwd}/views/build/index.js`));
+    app.get("/index.css", (req, res)=>res.sendFile(`${global.cwd}/views/build/index.css`));
+}

+ 10 - 0
views/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Workout Tracker</title>
+</head>
+<body>
+    <h1>Workout Tracker</h1>
+</body>
+</html>