-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Foundational work for trip planner integration
- Loading branch information
1 parent
a2d4027
commit 2dc3b7e
Showing
4 changed files
with
98 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { error, json } from '@sveltejs/kit'; | ||
|
||
export async function GET() { | ||
try { | ||
const response = await fetch( | ||
'https://otp.prod.sound.obaweb.org/otp/routers/default/plan?fromPlace=47.5423055%2C-122.38677&toPlace=47.639376%2C-122.128238', | ||
{ | ||
headers: { | ||
'Accept': 'application/json' | ||
} | ||
} | ||
); | ||
|
||
if (!response.ok) { | ||
throw error(response.status, `OpenTripPlanner API returned status ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
return json(data); | ||
|
||
} catch (err) { | ||
// If it's already a SvelteKit error, rethrow it | ||
if (err.status) throw err; | ||
|
||
// Otherwise wrap it in a 500 error | ||
throw error(500, { | ||
message: 'Failed to fetch trip planning data', | ||
error: err.message | ||
}); | ||
} | ||
} |