This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
wikipedia-game-solver/apps/api/start/routes.ts

31 lines
678 B
TypeScript
Raw Normal View History

2024-08-16 02:50:11 +02:00
/**
* Routes file
*
* The routes file is used for defining the HTTP routes.
* Routes are loaded automatically from "app/controllers".
2024-08-16 02:50:11 +02:00
*/
import fs from "node:fs"
import path from "node:path"
const CONTROLLERS_DIRECTORY_URL = new URL(
"../app/controllers/",
import.meta.url,
)
const controllers = (
await fs.promises.readdir(CONTROLLERS_DIRECTORY_URL, {
recursive: true,
withFileTypes: true,
})
).filter((item) => {
return item.isFile() && !item.name.includes(".test.")
})
await Promise.all(
controllers.map(async (controller) => {
const controllerPath = path.join(controller.parentPath, controller.name)
await import(controllerPath)
}),
)