Add express routes
This commit is contained in:
parent
ffd23217da
commit
4d1da02b5f
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Router } from "express";
|
||||||
|
import BookingController from "../controllers/booking.controller";
|
||||||
|
|
||||||
|
class BookingRoutes {
|
||||||
|
router = Router();
|
||||||
|
controller = new BookingController();
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.intializeRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
intializeRoutes() {
|
||||||
|
// Create a new Booking
|
||||||
|
this.router.post("/", this.controller.create);
|
||||||
|
|
||||||
|
// Retrieve all Bookings
|
||||||
|
this.router.get("/", this.controller.findAll);
|
||||||
|
|
||||||
|
// Retrieve a single Booking with id
|
||||||
|
this.router.get("/:id", this.controller.findOne);
|
||||||
|
|
||||||
|
// Update a Booking with id
|
||||||
|
this.router.put("/:id", this.controller.update);
|
||||||
|
|
||||||
|
// Delete a Booking with id
|
||||||
|
this.router.delete("/:id", this.controller.delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new BookingRoutes().router;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Router } from "express";
|
||||||
|
import ClientController from "../controllers/client.controller";
|
||||||
|
|
||||||
|
class ClientRoutes {
|
||||||
|
router = Router();
|
||||||
|
controller = new ClientController();
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.intializeRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
intializeRoutes() {
|
||||||
|
// Create a new Client
|
||||||
|
this.router.post("/", this.controller.create);
|
||||||
|
|
||||||
|
// Retrieve all Clients
|
||||||
|
this.router.get("/", this.controller.findAll);
|
||||||
|
|
||||||
|
// Retrieve a single Client with id
|
||||||
|
this.router.get("/:id", this.controller.findOne);
|
||||||
|
|
||||||
|
// Update a Client with id
|
||||||
|
this.router.put("/:id", this.controller.update);
|
||||||
|
|
||||||
|
// Delete a Client with id
|
||||||
|
this.router.delete("/:id", this.controller.delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new ClientRoutes().router;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Router } from "express";
|
||||||
|
import HotelController from "../controllers/hotel.controller";
|
||||||
|
|
||||||
|
class HotelRoutes {
|
||||||
|
router = Router();
|
||||||
|
controller = new HotelController();
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.intializeRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
intializeRoutes() {
|
||||||
|
// Create a new Hotel
|
||||||
|
this.router.post("/", this.controller.create);
|
||||||
|
|
||||||
|
// Retrieve all Hotels
|
||||||
|
this.router.get("/", this.controller.findAll);
|
||||||
|
|
||||||
|
// Retrieve a single Hotel with id
|
||||||
|
this.router.get("/:id", this.controller.findOne);
|
||||||
|
|
||||||
|
// Update a Hotel with id
|
||||||
|
this.router.put("/:id", this.controller.update);
|
||||||
|
|
||||||
|
// Delete a Hotel with id
|
||||||
|
this.router.delete("/:id", this.controller.delete);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new HotelRoutes().router;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { Application } from "express";
|
||||||
|
|
||||||
|
import hotelRoutes from "./hotel.routes";
|
||||||
|
import clientRoutes from "./client.routes";
|
||||||
|
import bookingRoutes from "./booking.routes";
|
||||||
|
|
||||||
|
export default class Routes {
|
||||||
|
constructor(app: Application) {
|
||||||
|
app.use("/api/hotels", hotelRoutes);
|
||||||
|
app.use("/api/client", clientRoutes);
|
||||||
|
app.use("/api/booking", bookingRoutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue