Skip to content

Commit

Permalink
Merge pull request #3 from kaiwalyakoparkar/dev
Browse files Browse the repository at this point in the history
Route hanling
  • Loading branch information
kaiwalyakoparkar authored Sep 4, 2021
2 parents 7c6d959 + dbedd63 commit 06073fa
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 3 deletions.
12 changes: 10 additions & 2 deletions controllers/operationsController.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
exports.getRequest = (req, res) => {
res.send('Hello');
const feed = require('../dev-data/data/feed.json');

exports.getFeed = (req, res) => {
res.status(200).json({
status: 'success',
results: feed.length,
data: {
feed,
},
});
};
167 changes: 167 additions & 0 deletions dev-data/data/feed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
[
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
},
{
"profilePicture": "https://i.imgur.com/R4ikJd1.jpg",
"username": "Andreas Brixen",
"posts": [
{
"postImg": "https://i.imgur.com/l8rN74g.png",
"caption": "A good old book."
}
],
"points": 80
}
]
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const app = express();
if (process.env.DEV_ENVIRONMENT === 'development') {
app.use(morgan('dev'));
}

app.use('/', require(path.join(__dirname, './routes/operationsRoute.js')));

module.exports = app;
2 changes: 1 addition & 1 deletion routes/operationsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const route = express.Router();

const operationsController = require('../controllers/operationsController.js');

route.get('/', operationsController.getRequest);
route.route('/').get(operationsController.getFeed);

module.exports = route;

0 comments on commit 06073fa

Please sign in to comment.