From 231ffac2caee5f8fe60a628498aa7346bdadc7ff Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 15:52:54 -0700 Subject: [PATCH 01/12] trying to deploy again --- netlify.toml | 2 +- netlify/functions/api.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/netlify.toml b/netlify.toml index 9b41f55..b19d844 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,7 +2,7 @@ publish = "public" [functions] - external_node_modules = ["express"] + external_node_modules = ["express", "mongoose"] node_bundler = "esbuild" [[redirects]] diff --git a/netlify/functions/api.js b/netlify/functions/api.js index ab110dd..3a19681 100644 --- a/netlify/functions/api.js +++ b/netlify/functions/api.js @@ -1,5 +1,4 @@ import serverless from "serverless-http"; +import { app } from ".../../server.js"; -const serverModule = await import("../../server.js"); - -export const handler = serverless(serverModule.app); +export const handler = serverless(app); From f72eeafe1abc578ebc3dc77a9d975b6937bc1ea3 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:01:18 -0700 Subject: [PATCH 02/12] kicking the toml file --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index b19d844..36d4405 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,6 +2,7 @@ publish = "public" [functions] + directory = "netlify/functions" external_node_modules = ["express", "mongoose"] node_bundler = "esbuild" From 058ca2ffc615a617213e1c0c48047ed636624f83 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:09:07 -0700 Subject: [PATCH 03/12] changing build location --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 36d4405..44ccd67 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,5 +1,5 @@ [build] - publish = "public" + publish = "." [functions] directory = "netlify/functions" From 48edbdfd5f14c7270e928077097f2c643e59c203 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:12:56 -0700 Subject: [PATCH 04/12] trying to override netlify ui --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index 44ccd67..12f9ae3 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,5 +1,6 @@ [build] publish = "." + ignore = "/bin/false" [functions] directory = "netlify/functions" From e63e163d1e2c76b120066f7dd2de3f5786d53930 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:35:54 -0700 Subject: [PATCH 05/12] fixing chaos committed hopefully --- netlify.toml | 5 ++--- netlify/functions/api.js | 2 +- server.js | 42 ++++++++++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/netlify.toml b/netlify.toml index 12f9ae3..bb69c64 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,14 +1,13 @@ [build] - publish = "." + publish = "public" ignore = "/bin/false" [functions] directory = "netlify/functions" - external_node_modules = ["express", "mongoose"] + external_node_modules = ["express", "mongoose", "ejs"] node_bundler = "esbuild" [[redirects]] from = "/*" to = "/.netlify/functions/api/:splat" status = 200 - force = true \ No newline at end of file diff --git a/netlify/functions/api.js b/netlify/functions/api.js index 3a19681..b74ebc1 100644 --- a/netlify/functions/api.js +++ b/netlify/functions/api.js @@ -1,4 +1,4 @@ import serverless from "serverless-http"; -import { app } from ".../../server.js"; +import { app } from "../../server.js"; export const handler = serverless(app); diff --git a/server.js b/server.js index 9689eb9..41ef92a 100644 --- a/server.js +++ b/server.js @@ -6,14 +6,19 @@ import dotenv from "dotenv"; dotenv.config(); -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +// const __filename = fileURLToPath(import.meta.url); +// const __dirname = path.dirname(__filename); export const app = express(); + +const ROOT = process.cwd(); + app.set("view engine", "ejs"); -app.set("views", path.join(__dirname, "views")); +// app.set("views", path.join(__dirname, "views")); +app.use(express.static(path.join(ROOT, "public"))); app.use(express.static("public")); -app.use("/managers", express.static(path.join(__dirname, "managers"))); +// app.use("/managers", express.static(path.join(__dirname, "managers"))); +app.use("/managers", express.static(path.join(ROOT, "managers"))); app.use(express.json()); /** @@ -27,11 +32,32 @@ app.use((req, _, next) => { next(); }); -mongoose.connect(process.env.MONGODB_URI); +// mongoose.connect(process.env.MONGODB_URI); +let mongoReady = false; +async function ensureMongo() { + if (mongoReady && mongoose.connection.readyState === 1) return; + if (!process.env.MONGODB_URI) { + console.warn("Mongo keys are missing"); + return; + } + await mongoose.connect(process.env.MONGODB_URI); + mongoReady = true; + console.log("Mongo connected"); + console.log("Database of madness has started!"); +} + +app.use(async (_req, _res, next) => { + try { + await ensureMongo(); + next(); + } catch (error) { + next(error); + } +}); -const db = mongoose.connection; -db.on("error", (error) => console.log(error)); -db.once("open", () => console.log("Database of madness has started!")); +// const db = mongoose.connection; +// db.on("error", (error) => console.log(error)); +// db.once("open", () => console.log("Database of madness has started!")); import abilitiesRouter from "./routes/routerAbilities.js"; app.use("/abilities", abilitiesRouter); From 268c8a5e1e5fb35481ace5846ce40a01bb71c877 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:57:09 -0700 Subject: [PATCH 06/12] adding tester function --- netlify/functions/chaos.js | 3 +++ server.js | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 netlify/functions/chaos.js diff --git a/netlify/functions/chaos.js b/netlify/functions/chaos.js new file mode 100644 index 0000000..d6fed59 --- /dev/null +++ b/netlify/functions/chaos.js @@ -0,0 +1,3 @@ +export const handler = async () => { + return { statusCode: 200, body: "deployment chaos on netlify" }; +}; diff --git a/server.js b/server.js index 41ef92a..6187d7c 100644 --- a/server.js +++ b/server.js @@ -14,12 +14,12 @@ export const app = express(); const ROOT = process.cwd(); app.set("view engine", "ejs"); -// app.set("views", path.join(__dirname, "views")); +app.set("views", path.join(ROOT, "views")); app.use(express.static(path.join(ROOT, "public"))); -app.use(express.static("public")); -// app.use("/managers", express.static(path.join(__dirname, "managers"))); app.use("/managers", express.static(path.join(ROOT, "managers"))); app.use(express.json()); +// app.set("views", path.join(__dirname, "views")); +// app.use("/managers", express.static(path.join(__dirname, "managers"))); /** * Logs all incoming requests for debugging purposes From 2b4c218368c0b6f4324f5f78c64b1082e9856fb3 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:22:00 -0700 Subject: [PATCH 07/12] updating build command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 736d93b..9776455 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "keywords": [], "scripts": { "dev": "vite", - "build": "echo 'Build complete'", + "build": "node -e \"console.log('build ok')\"", "start": "node server.js", "server": "nodemon --watch './' --ext ts,js --exec 'tsx' server.js", "macStart": "nodemon --watch './' --ext ts --exec 'node --loader ts-node/esm' server.js", From 80453f2ca7b4b24d2709e4936edb3dc867086fcc Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:40:25 -0700 Subject: [PATCH 08/12] removing vite --- package-lock.json | 194 ++++++++++------------------------------------ package.json | 3 +- vite.config.js | 19 ----- 3 files changed, 44 insertions(+), 172 deletions(-) delete mode 100644 vite.config.js diff --git a/package-lock.json b/package-lock.json index 3f3ba40..7e4067f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,8 +24,7 @@ "nodemon": "^3.1.10", "tsx": "^4.20.3", "typescript": "~5.8.3", - "undici-types": "^7.12.0", - "vite": "^7.0.4" + "undici-types": "^7.12.0" } }, "node_modules/@babel/code-frame": { @@ -998,12 +997,12 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "android" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-android-arm64": { "version": "4.45.1", @@ -1012,12 +1011,12 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "android" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-darwin-arm64": { "version": "4.45.1", @@ -1026,12 +1025,12 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "darwin" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-darwin-x64": { "version": "4.45.1", @@ -1040,12 +1039,12 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "darwin" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-freebsd-arm64": { "version": "4.45.1", @@ -1054,12 +1053,12 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "freebsd" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-freebsd-x64": { "version": "4.45.1", @@ -1068,12 +1067,12 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "freebsd" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { "version": "4.45.1", @@ -1082,12 +1081,12 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { "version": "4.45.1", @@ -1096,12 +1095,12 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm64-gnu": { "version": "4.45.1", @@ -1110,12 +1109,12 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm64-musl": { "version": "4.45.1", @@ -1124,12 +1123,12 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-loongarch64-gnu": { "version": "4.45.1", @@ -1138,12 +1137,12 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { "version": "4.45.1", @@ -1152,12 +1151,12 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { "version": "4.45.1", @@ -1166,12 +1165,12 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-riscv64-musl": { "version": "4.45.1", @@ -1180,12 +1179,12 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-s390x-gnu": { "version": "4.45.1", @@ -1194,12 +1193,12 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-x64-gnu": { "version": "4.45.1", @@ -1208,12 +1207,12 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-x64-musl": { "version": "4.45.1", @@ -1222,12 +1221,12 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-win32-arm64-msvc": { "version": "4.45.1", @@ -1236,12 +1235,12 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "win32" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-win32-ia32-msvc": { "version": "4.45.1", @@ -1250,12 +1249,12 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "win32" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-win32-x64-msvc": { "version": "4.45.1", @@ -1264,12 +1263,12 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ "win32" - ] + ], + "peer": true }, "node_modules/@so-ric/colorspace": { "version": "1.1.6", @@ -3185,21 +3184,6 @@ "pend": "~1.2.0" } }, - "node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } - } - }, "node_modules/fecha": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", @@ -3356,7 +3340,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -5216,8 +5199,9 @@ "version": "4.45.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.45.1.tgz", "integrity": "sha512-4iya7Jb76fVpQyLoiVpzUrsjQ12r3dM7fIVz+4NwoYvZOShknRmiv+iu9CClZml5ZLGb0XMcYLutK6w9tgxHDw==", - "devOptional": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -5776,23 +5760,6 @@ "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", "license": "MIT" }, - "node_modules/tinyglobby": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", - "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "fdir": "^6.4.4", - "picomatch": "^4.0.2" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/SuperchupuDev" - } - }, "node_modules/tmp": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", @@ -6108,81 +6075,6 @@ "node": ">= 0.8" } }, - "node_modules/vite": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.0.6.tgz", - "integrity": "sha512-MHFiOENNBd+Bd9uvc8GEsIzdkn1JxMmEeYX35tI3fv0sJBUTfW5tQsoaOwuY4KhBI09A3dUJ/DXf2yxPVPUceg==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "^0.25.0", - "fdir": "^6.4.6", - "picomatch": "^4.0.3", - "postcss": "^8.5.6", - "rollup": "^4.40.0", - "tinyglobby": "^0.2.14" - }, - "bin": { - "vite": "bin/vite.js" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "funding": { - "url": "https://github.com/vitejs/vite?sponsor=1" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - }, - "peerDependencies": { - "@types/node": "^20.19.0 || >=22.12.0", - "jiti": ">=1.21.0", - "less": "^4.0.0", - "lightningcss": "^1.21.0", - "sass": "^1.70.0", - "sass-embedded": "^1.70.0", - "stylus": ">=0.54.8", - "sugarss": "^5.0.0", - "terser": "^5.16.0", - "tsx": "^4.8.1", - "yaml": "^2.4.2" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "jiti": { - "optional": true - }, - "less": { - "optional": true - }, - "lightningcss": { - "optional": true - }, - "sass": { - "optional": true - }, - "sass-embedded": { - "optional": true - }, - "stylus": { - "optional": true - }, - "sugarss": { - "optional": true - }, - "terser": { - "optional": true - }, - "tsx": { - "optional": true - }, - "yaml": { - "optional": true - } - } - }, "node_modules/webidl-conversions": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", diff --git a/package.json b/package.json index 9776455..73149a7 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ "nodemon": "^3.1.10", "tsx": "^4.20.3", "typescript": "~5.8.3", - "undici-types": "^7.12.0", - "vite": "^7.0.4" + "undici-types": "^7.12.0" }, "dependencies": { "@netlify/functions": "^4.2.7", diff --git a/vite.config.js b/vite.config.js deleted file mode 100644 index 6fac2df..0000000 --- a/vite.config.js +++ /dev/null @@ -1,19 +0,0 @@ -import { defineConfig } from "vite"; - -export default defineConfig({ - root: "./public", - server: { - port: 5173, - proxy: { - // Proxy API calls to the express server - "/api": { - target: "http://localhost:3001", - changeOrigin: true, - }, - }, - }, - build: { - outDir: "../dist", - emptyOutDir: true, - }, -}); From 60c48d585b10f6e4c406947b8e9d68702e83362b Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:47:21 -0700 Subject: [PATCH 09/12] removing all vite --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 73149a7..d0705d0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "type": "module", "keywords": [], "scripts": { - "dev": "vite", "build": "node -e \"console.log('build ok')\"", "start": "node server.js", "server": "nodemon --watch './' --ext ts,js --exec 'tsx' server.js", From 86f15a794d20b58d6a560ca5d5ee8ab1ce889800 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:57:45 -0700 Subject: [PATCH 10/12] kicking toml file --- netlify.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/netlify.toml b/netlify.toml index bb69c64..c14db1b 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,3 @@ -[build] - publish = "public" - ignore = "/bin/false" - [functions] directory = "netlify/functions" external_node_modules = ["express", "mongoose", "ejs"] From e732eb0e7c503cbbb4a9436b239d12b5f0e25daa Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 18:02:07 -0700 Subject: [PATCH 11/12] testing redirects --- netlify.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/netlify.toml b/netlify.toml index c14db1b..b130575 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,7 +3,4 @@ external_node_modules = ["express", "mongoose", "ejs"] node_bundler = "esbuild" -[[redirects]] - from = "/*" - to = "/.netlify/functions/api/:splat" - status = 200 + From 9325cc0e60ec441603234cb8b8e235c4ff873e79 Mon Sep 17 00:00:00 2001 From: TokiLoshi <103384402+TokiLoshi@users.noreply.github.com> Date: Thu, 9 Oct 2025 19:08:03 -0700 Subject: [PATCH 12/12] updating redirects --- netlify.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index b130575..6cb261d 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,4 +3,6 @@ external_node_modules = ["express", "mongoose", "ejs"] node_bundler = "esbuild" - +[[redirects]] + from = "/api/*" + to = "/.netlify/functions/api/:splat"