ソースを参照

Add verbose coloring, fix local web running in docker

ghorsington 4 年 前
コミット
c339e1ba9d

+ 6 - 0
docker-compose.dev.yml

@@ -16,6 +16,12 @@ services:
   mongo:
     ports:
       - "27017:27017"
+
+  web:
+    environment: 
+      SECURE: "FALSE"
+    ports:
+      - "3000:80"
   
   mongo-express:
     image: mongo-express

+ 1 - 0
docker-compose.yml

@@ -57,6 +57,7 @@ services:
       TYPEORM_DATABASE: ${DB_NAME}
       WEB_DATA_PATH: /web_data
       PORT: "80"
+      SECURE: "TRUE"
     volumes:
       - web-data:/web_data
 

+ 1 - 0
web/src/routes/logs.svelte

@@ -16,6 +16,7 @@
     let error = "";
 
     const LEVEL_COLORS: Record<string, string> = {
+        "verbose": "#A0AEC0",
         "info": "#EFF2F7",
         "warn": "#ECC94B",
         "error": "#C53030",

+ 4 - 3
web/src/server.ts

@@ -8,15 +8,16 @@ import session from "cookie-session";
 import sirv from "sirv";
 import { createConnection, getConnectionOptions } from "typeorm";
 import { DB_ENTITIES } from "@shared/db/entities";
-import { eventLogger, logger } from "./utils/logging";
+import { logger } from "./utils/logging";
 import { AppSession } from "./utils/session";
 
 const PORT = process.env.PORT; // eslint-disable-line prefer-destructuring
 // @ts-ignore -- creates a warning after `rollup-plugin-replace` (set up in `rollup.config.js`)
 // replaces `process.env.NODE_ENV` with `"production"` during `prod`
 const dev = process.env.NODE_ENV === "development";
+const secure = process.env.SECURE === "TRUE";
 
-logger.info("Staring webserver to port %s", PORT);
+logger.info("Staring webserver to port %s (is dev: %s)", PORT, dev);
 
 const key = process.env.WEB_COOKIE_KEY;
 
@@ -39,7 +40,7 @@ const createSapperServer = async (): Promise<Express> => {
         session({
             secret: key,
             name: "session",
-            secure: !dev,
+            secure,
         }),
         compression({ threshold: 0 }),
         sirv("static", { dev }),

+ 1 - 3
web/src/utils/logging.ts

@@ -31,11 +31,9 @@ export const logger = createLogger({
     },
 });
 
-export const LOGGER_NAME = "WEB";
-
 export const eventLogger = createEventLogger({
     host: process.env.MONGO_DB_HOST ?? "",
     password: process.env.MONGO_DB_USERNAME ?? "",
     username: process.env.MONGO_DB_PASSWORD ?? "",
-    name: LOGGER_NAME,
+    name: "WEB",
 });