Created
November 14, 2016 15:59
-
-
Save Juraci/2861bbe5b30203ed576231dd0ca6d442 to your computer and use it in GitHub Desktop.
ES 2015 Node.js code
This file contains 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 express from 'express'; | |
import bodyParser from 'body-parser'; | |
import GoalsController from '../controllers/goals'; | |
const router = express.Router(); | |
const jsonParser = bodyParser.json(); | |
export default (datasource) => { | |
const Goal = datasource.models.Goal; | |
const goalsController = new GoalsController(Goal); | |
router.route('/') | |
.get((req, res) => { | |
goalsController.findAll() | |
.then((result) => { | |
res.status(result.status).json(result.data); | |
}); | |
}); | |
return router; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment