import { Context , Handler } from 'aws-lambda' ; import { HttpResponse , Stock } from './types' ; import { HotStockService } from './hotStockService' ; description param event param context const process = async ( event , context ) => { try { console . info ( 'hotStockHandler.process' , { event } ) ; const hotStocks = await HotStockService . getHotStocks ( ) ; const response = new HttpResponse ( { statusCode : 200 , body : JSON . stringify ( hotStocks ) , headers : { "Access-Control-Allow-Origin" : "*" , "Access-Control-Allow-Credentials" : true , "Cache-Control" : "public, max-age=14400, s-maxage=14400'" } } ) ; context . succeed ( response ) ; } catch ( error ) { console . error ( 'hotStockHandler.error' , { error } ) ; let body = '' ; try { body = JSON . stringify ( error ) ; } catch ( ex ) { body = 'Unable to stringify result' ; } const response = new HttpResponse ( { statusCode : 500 , body , headers : { "Access-Control-Allow-Credentials" : true , "Cache-Control" : "no-cache" } } ) ; context . succeed ( response ) ; } } ; export { process } ;