Skip to content

Commit

Permalink
looser config parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Feb 27, 2024
1 parent b54c97f commit c75fbab
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ServerlessEvent,
ServerlessResponse
} from './utils'
import { OfflineResponse } from '@opentripplanner/geocoder/lib/apis/offline'

Check warning on line 23 in handler.ts

View workflow job for this annotation

GitHub Actions / test-lambda-function

`@opentripplanner/geocoder/lib/apis/offline` import should occur before import of `./utils`

// This plugin must be imported via cjs to ensure its existence (typescript recommendation)
const BugsnagPluginAwsLambda = require('@bugsnag/plugin-aws-lambda')
Expand Down Expand Up @@ -55,7 +56,18 @@ if (!GEOCODERS) {
const geocoders = JSON.parse(GEOCODERS)
const backupGeocoders = BACKUP_GEOCODERS && JSON.parse(BACKUP_GEOCODERS)
// Serverless is not great about null
const pois = POIS && POIS !== "null" ? JSON.parse(POIS) : []
const pois = POIS && POIS !== "null" ? (JSON.parse(POIS) as OfflineResponse).map((poi) => {

Check failure on line 59 in handler.ts

View workflow job for this annotation

GitHub Actions / test-lambda-function

Replace `·POIS·&&·POIS·!==·"null"` with `⏎··POIS·&&·POIS·!==·'null'⏎···`
if (typeof poi.lat === 'string') {
poi.lat = parseFloat(poi.lat)
}
if (typeof poi.lon === 'string') {
poi.lon = parseFloat(poi.lon)
}
return poi
}) : []

console.log(pois)


if (geocoders.length !== backupGeocoders.length) {
throw new Error('Error: BACKUP_GEOCODERS is not set to the same length as GEOCODERS')
Expand Down

0 comments on commit c75fbab

Please sign in to comment.