Skip to content

Instantly share code, notes, and snippets.

@Juraci
Created November 14, 2016 15:59
Show Gist options
  • Save Juraci/2861bbe5b30203ed576231dd0ca6d442 to your computer and use it in GitHub Desktop.
Save Juraci/2861bbe5b30203ed576231dd0ca6d442 to your computer and use it in GitHub Desktop.
ES 2015 Node.js code
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