Created
May 23, 2016 23:15
-
-
Save stewhouston/8cccedf560b3db6e38ad116b5a410301 to your computer and use it in GitHub Desktop.
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 { 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