diff --git a/src/app.ts b/src/app.ts index 815385b..f27a353 100644 --- a/src/app.ts +++ b/src/app.ts @@ -10,6 +10,7 @@ dotenv.config(); // Utils import log from "./utils/logger.ts"; import * as path from "path"; +import route from "./routes/api/route"; //-----------------------------------------------> // Express - setup & configuration @@ -26,7 +27,17 @@ app.set("views", path.join(import.meta.dirname, "views")); app.set("view engine", "ejs"); //-----------------------------------------------> -// Express - routing setup +// Express - external routers +//-----------------------------------------------> + +// Import routes +import apiRouter from "./routes/api/route.js"; + +// Use routes +app.use("/api", apiRouter); + +//-----------------------------------------------> +// Express - main route //-----------------------------------------------> app.get("/", (req: Request, res: Response) => { diff --git a/src/routes/api/route.js b/src/routes/api/route.js new file mode 100644 index 0000000..4adf6bc --- /dev/null +++ b/src/routes/api/route.js @@ -0,0 +1,27 @@ +//-----------------------------------------------> +// Imports +//-----------------------------------------------> + +import { Router } from "express"; + +//-----------------------------------------------> +// Router - setup & configuration +//-----------------------------------------------> + +const router = Router(); + +//-----------------------------------------------> +// Router - implement routes +//-----------------------------------------------> + +// Import routes +import userRouter from "./v1/user.js"; + +// Use routes +router.use("/v1/user", userRouter); + +//-----------------------------------------------> +// Router - export router instance +//-----------------------------------------------> + +export default router; \ No newline at end of file diff --git a/src/routes/api/v1/user.js b/src/routes/api/v1/user.js new file mode 100644 index 0000000..59461c3 --- /dev/null +++ b/src/routes/api/v1/user.js @@ -0,0 +1,23 @@ +//-----------------------------------------------> +// Imports +//-----------------------------------------------> + +import { Router } from "express"; + +//-----------------------------------------------> +// Router - setup & configuration +//-----------------------------------------------> + +const router = Router(); + +//-----------------------------------------------> +// Router - endpoints +//-----------------------------------------------> + +router.get("/", () => {}); + +//-----------------------------------------------> +// Router - export router instance +//-----------------------------------------------> + +export default router; \ No newline at end of file