Skip to content

Instantly share code, notes, and snippets.

@stewhouston
Created May 23, 2016 23:15
Show Gist options
  • Save stewhouston/8cccedf560b3db6e38ad116b5a410301 to your computer and use it in GitHub Desktop.
Save stewhouston/8cccedf560b3db6e38ad116b5a410301 to your computer and use it in GitHub Desktop.
import { Route, RouteControllerDecorator as RouteController } from './lib/octv';
import { GamesService } from './services';
module.exports = (function() {
@RouteController({
providers: ['express']
})
class GamesController {
baseUrl:string = '/games';
gamesService:GamesService;
constructor(private app, private express) {
this.gamesService = new GamesService(app.octvConfig);
}
routes:Array<Route> = [
new Route('get', '/json', (req, res) => {
this.gamesService.getAllGames()
.then(gamesJson => {
res.status(200);
res.setHeader('Content-Type', 'application/json');
res.send(gamesJson);
})
.catch(err => {
console.log(err);
});
})
];
}
return GamesController;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment