Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const awsServices = require('@cumulus/aws-client/services');
const log = require('@cumulus/common/log');
const messageConsumer = require('./message-consumer');
const Kinesis = awsServices.kinesis();
const tallyReducer = (acc, cur) => acc + cur;
/**
* This function will accept as valid input an event whose `endTimestamp` and `startTimestamp`
* fields must contain valid input to the `new Date()` constructor if they exist.
* They will then be populated into `process.env` as ISO strings.
*
* @param {Object} event - input object
*/
const configureTimestampEnvs = (event) => {
if (!process.env.endTimestamp && event.endTimestamp) {
const dateObj = new Date(event.endTimestamp);
if (Number.isNaN(dateObj.valueOf())) {
throw new TypeError(`endTimestamp ${event.endTimestamp} is not a valid input for new Date().`);
}
process.env.endTimestamp = dateObj.toISOString();