✨ (routes): implement new API routes
feat: add new API route feat: add user endpoint to API route
This commit is contained in:
parent
a3bfaf4d93
commit
ecddd4c7b3
3 changed files with 62 additions and 1 deletions
13
src/app.ts
13
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) => {
|
||||
|
|
27
src/routes/api/route.js
Normal file
27
src/routes/api/route.js
Normal file
|
@ -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;
|
23
src/routes/api/v1/user.js
Normal file
23
src/routes/api/v1/user.js
Normal file
|
@ -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;
|
Loading…
Reference in a new issue