From eb9960458555119d0701236f1ec274c2ed21792c Mon Sep 17 00:00:00 2001 From: Silas <91368591+Daaisukidayo@users.noreply.github.com> Date: Fri, 1 May 2026 16:58:44 +0200 Subject: [PATCH] Refactor route loading to use dynamic import --- src/api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api.js b/src/api.js index 0278e8f..857671c 100644 --- a/src/api.js +++ b/src/api.js @@ -57,8 +57,8 @@ async function loadRoutes() { const files = await scanRoutes(path); for (const file of files) { try { - const modules = require(file); - delete require.cache[require.resolve(file)]; + const imported = await import(`file://${file}`); + const modules = imported.default || imported; const array = Array.isArray(modules) ? modules : [modules]; for (const module of array) { if (validateRoute(module)) registerRoute(module); @@ -180,4 +180,4 @@ function startServer() { }); } -module.exports = { initializer, updateRoutes }; \ No newline at end of file +module.exports = { initializer, updateRoutes };