wikipedia-game-solver/apps/api/start/routes.ts
Théo LUDWIG 4e707008f8
All checks were successful
Chromatic / chromatic (push) Successful in 1m55s
CI / ci (push) Successful in 4m33s
CI / commitlint (push) Successful in 15s
chore(api): improve DX (Developer Experience)
2024-08-19 22:11:33 +01:00

31 lines
678 B
TypeScript

/**
* Routes file
*
* The routes file is used for defining the HTTP routes.
* Routes are loaded automatically from "app/controllers".
*/
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)
}),
)