TS-Generic-Structure/src/routes/GenericRouter.ts
2025-01-17 14:07:39 +01:00

16 lines
647 B
TypeScript

import express from "express";
import GenericController from "../controller/GenericController";
import GenericService from "../services/GenericService";
import BaseEntity from "../entities/baseEntity";
export default class GenericRouter<
Controller extends GenericController<Service, Repository>,
Service extends GenericService<Repository>,
Repository extends BaseEntity
> {
public router = express.Router({ mergeParams: true });
constructor(protected controller: Controller) {
this.router.get("/", (req, res) => this.controller.getAll(req, res));
this.router.get("/:id", (req, res) => this.controller.getById(req, res));
}
}