From 3c63518b99957d3e304da139ddd902299d875ed2 Mon Sep 17 00:00:00 2001 From: ramya Date: Tue, 1 Mar 2022 15:56:27 -0500 Subject: [PATCH] Added sample fibanocci function #40 --- .../api/controller.js | 50 +++++++++++++++++-- .../api/routes.js | 4 +- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/weather-data-ingestor-microservice/api/controller.js b/weather-data-ingestor-microservice/api/controller.js index 88f3ffb..28e4232 100644 --- a/weather-data-ingestor-microservice/api/controller.js +++ b/weather-data-ingestor-microservice/api/controller.js @@ -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) { @@ -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; \ No newline at end of file + }; \ No newline at end of file diff --git a/weather-data-ingestor-microservice/api/routes.js b/weather-data-ingestor-microservice/api/routes.js index d238b90..37065b7 100644 --- a/weather-data-ingestor-microservice/api/routes.js +++ b/weather-data-ingestor-microservice/api/routes.js @@ -2,6 +2,6 @@ const controller = require('./controller'); module.exports = function(app) { app.route('/api/uri/images/') - .post(controller.postS3url); - // + .post(controller.fibonacci); + }; \ No newline at end of file