diff --git a/routes/apps.js b/routes/apps.js index 935c3d3..8ef001c 100644 --- a/routes/apps.js +++ b/routes/apps.js @@ -1,4 +1,18 @@ const express = require('express'); const router = express.Router(); +const data = require('../data/apps.json'); + + +router.get('/', function(req, res, next) { + res.json( data ); +}); + + +router.get('/:id', function(req, res, next) { + const id = parseInt(req.params.id) + const item = data.find(item => item.id === id) + res.json(item || {}); +}); + module.exports = router; \ No newline at end of file