Created
November 23, 2018 11:51
-
-
Save SaifRehman/0fbe8b3b69bec7b5db5e1afd6717a175 to your computer and use it in GitHub Desktop.
routes.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Router } from "express"; | |
| import { Request, Response, NextFunction } from "express"; | |
| import { ItemController } from "../listing/lib/controllers/crmController"; | |
| import "reflect-metadata"; | |
| class ListingMongoController { | |
| public itemController: ItemController = new ItemController(); | |
| public router: Router; | |
| constructor() { | |
| this.router = Router(); | |
| this.routes(); | |
| } | |
| private routes() { | |
| this.router.get("/healthz", (_, res) => { | |
| res.status(200).send("healthz"); | |
| }); | |
| this.router.get( | |
| "/listItems", | |
| (req: Request, res: Response, next: NextFunction) => { | |
| next(); | |
| }, | |
| this.itemController.getItem | |
| ); | |
| this.router.post( | |
| "/listItems", | |
| (req: Request, res: Response, next: NextFunction) => { | |
| next(); | |
| }, | |
| this.itemController.addNewItem | |
| ); | |
| this.router.get( | |
| "/listItems/:ID", | |
| (_, res: Response, next: NextFunction) => { | |
| next(); | |
| }, | |
| this.itemController.getItemById | |
| ); | |
| this.router.put( | |
| "/listItems/:ID", | |
| (_, res: Response, next: NextFunction) => { | |
| next(); | |
| }, | |
| this.itemController.updateItem | |
| ); | |
| this.router.delete( | |
| "/listItems/:ID", | |
| (_, res: Response, next: NextFunction) => { | |
| next(); | |
| }, | |
| this.itemController.deleteItem | |
| ); | |
| } | |
| } | |
| export default new ListingMongoController().router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment