Skip to content

Commit

Permalink
Added sample fibanocci function #40
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya committed Mar 1, 2022
1 parent d6a4df5 commit 3c63518
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
50 changes: 47 additions & 3 deletions weather-data-ingestor-microservice/api/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,51 @@ const AWS = require('aws-sdk');
Delimiter: '/',
};

const fib = (n)=> {
if (n == 0 || n == 1)
return n;
else
return fib(n - 1) + fib(n - 2);
}

// var controllers = {
// postS3url: function(req, res) {
// const { body } = req;
// console.log("body=",req.body)
// const { date, time:hour, datacenter:radar } = body;
// const [year, month, day] = date.split("-")

// BucketConfig.Prefix = `${year}/${month}/${day}/${radar}/`;

// S3.makeUnauthenticatedRequest('listObjects', BucketConfig, (err, data) => {
// if (err) {
// res.status(500).send();
// }
// else {
// const result = [];

// if (data) {
// const { Contents } = data;
// if (Contents.length) {
// var hour_ = hour.substring(0,2);
// Contents
// .forEach(({ Key }) => {
// const [, hourString] = Key.split("_");
// const hr = hourString.substring(0, 2);
// if (hr === hour_) {
// result.push(Key)
// }
// })
// }
// }
// console.log(result)
// return res.json(result.slice(0, 4))
// res.json(result.slice(0, 4))
// }
// })
// },
// };
module.exports.fib = fib

var controllers = {
postS3url: function(req, res) {
Expand Down Expand Up @@ -40,10 +85,9 @@ const AWS = require('aws-sdk');
}
}
console.log(result)
return res.json(result.slice(0, 4))
res.json(result.slice(0, 4))
}
})
},
};

module.exports = controllers;
};
4 changes: 2 additions & 2 deletions weather-data-ingestor-microservice/api/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const controller = require('./controller');

module.exports = function(app) {
app.route('/api/uri/images/')
.post(controller.postS3url);
//
.post(controller.fibonacci);

};

0 comments on commit 3c63518

Please sign in to comment.