Skip to content

Instantly share code, notes, and snippets.

@pleerock
Created May 17, 2016 07:42
Show Gist options
  • Save pleerock/6ccceaf518b77593f700af37552cf2ad to your computer and use it in GitHub Desktop.
Save pleerock/6ccceaf518b77593f700af37552cf2ad to your computer and use it in GitHub Desktop.
import {Request, Response} from "express";
import {JsonController, Get, Post, Put, Patch, Delete} from "routing-controllers";
@JsonController()
export class BlogController {
@Get("/blogs")
getAll() {
return [
{ id: 1, name: "Blog 1!" },
{ id: 2, name: "Blog 2!" },
];
}
@Get("/blogs/:id")
getOne(@Req() request: Request, @Res() response: Response) {
return { id: request.param.id, name: "Blog!"};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment