Created
May 1, 2017 10:21
-
-
Save gorkamu/33156050a714e5f2f93a95002754767c to your computer and use it in GitHub Desktop.
Example of controller in Node.js
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
'use strict' | |
function getAlbum(req, res){ | |
var id = req.params.id; | |
res.status(200).send({ | |
data: id, | |
}); | |
} | |
function getAlbums(req, res){ | |
res.status(200).send({ | |
data:albums | |
}); | |
} | |
function saveAlbum(req, res){ | |
var params = req.body; | |
res.status(200).send({ | |
album: params | |
}); | |
} | |
function updateAlbum(req, res){ | |
var params = req.body; | |
res.status(200).send({ | |
album: params | |
}); | |
} | |
function deleteAlbum(req, res){ | |
var id = req.params.id; | |
res.status(200).send({ | |
data: id, | |
}); | |
} | |
module.exports = { | |
getAlbum, | |
getAlbums, | |
saveAlbum, | |
updateAlbum, | |
deleteAlbum | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment