Skip to content

Instantly share code, notes, and snippets.

@pleerock
Created May 17, 2016 07:16
Show Gist options
  • Save pleerock/c8007ef2233d834894ee53ebfb165389 to your computer and use it in GitHub Desktop.
Save pleerock/c8007ef2233d834894ee53ebfb165389 to your computer and use it in GitHub Desktop.
import {Request, Response} from "express";
import {Controller, Get, Post, Put, Patch, Delete} from "routing-controllers";
@Controller()
export class BlogController {
@Get("/blogs")
getAll() {
return "Hello Blogs";
}
@Get("/blogs/:id")
getOne(@Req() request: Request, @Res() response: Response) {
return "This is blog #" + request.param.id;
}
@Post("/blogs")
post(@Req() request: Request) {
return "Blog " + request.body + " saved!";
}
@Put("/blogs/:id")
put(@Req() request: Request) {
return "Blog " + request.body + " saved!";
}
@Delete("/blogs/:id")
remove(@Req() request: Request) {
return "Blog #" + request.params.id + " has been removed!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment