-
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.
Merge pull request #26 from OneBusAway/feature/url-change
Adds Stop Details Page
- Loading branch information
Showing
10 changed files
with
102 additions
and
28 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,17 @@ | ||
import { error, json } from '@sveltejs/kit'; | ||
|
||
import { PUBLIC_OBA_SERVER_URL as baseURL } from '$env/static/public'; | ||
import { PRIVATE_OBA_API_KEY as apiKey } from '$env/static/private'; | ||
|
||
export default async function(stopID) { | ||
const apiURL = `${baseURL}/api/where/arrivals-and-departures-for-stop/${stopID}.json?key=${apiKey}`; | ||
const response = await fetch(apiURL); | ||
|
||
if (!response.ok) { | ||
error(500, 'Unable to fetch arrivals-and-departures-for-stop.'); | ||
return; | ||
} | ||
|
||
const data = await response.json(); | ||
return json(data); | ||
} |
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,16 @@ | ||
import { error, json } from '@sveltejs/kit'; | ||
|
||
import { PUBLIC_OBA_SERVER_URL as baseURL } from '$env/static/public'; | ||
import { PRIVATE_OBA_API_KEY as apiKey } from '$env/static/private'; | ||
|
||
export default async function(stopID) { | ||
const apiURL = `${baseURL}/api/where/stop/${stopID}.json?key=${apiKey}`; | ||
const response = await fetch(apiURL); | ||
|
||
if (!response.ok) { | ||
return error(500, 'Unable to fetch arrivals-and-departures-for-stop.'); | ||
} | ||
|
||
const data = await response.json(); | ||
return json(data); | ||
} |
18 changes: 2 additions & 16 deletions
18
src/routes/api/oba/arrivals-and-departures-for-stop/[id]/+server.js
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 |
---|---|---|
@@ -1,20 +1,6 @@ | ||
import { error, json } from '@sveltejs/kit'; | ||
|
||
import { PUBLIC_OBA_SERVER_URL as baseURL } from '$env/static/public'; | ||
|
||
import { PRIVATE_OBA_API_KEY as apiKey } from '$env/static/private'; | ||
import arrivalDepartureAPI from '$lib/RestAPI/arrivalsAndDeparturesForStop'; | ||
|
||
/** @type {import('./$types').RequestHandler} */ | ||
export async function GET({ params }) { | ||
const stopID = params.id; | ||
const apiURL = `${baseURL}/api/where/arrivals-and-departures-for-stop/${stopID}.json?key=${apiKey}`; | ||
const response = await fetch(apiURL); | ||
|
||
if (!response.ok) { | ||
error(500, 'Unable to fetch arrivals-and-departures-for-stop.'); | ||
return; | ||
} | ||
|
||
const data = await response.json(); | ||
return json(data); | ||
return arrivalDepartureAPI(params.id); | ||
} |
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,6 @@ | ||
import stopAPI from '$lib/RestAPI/stop'; | ||
|
||
/** @type {import('./$types').RequestHandler} */ | ||
export async function GET({ params }) { | ||
return stopAPI(params.stopID); | ||
} |
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,16 @@ | ||
import stopAPI from '$lib/RestAPI/stop.js'; | ||
import arrivalDepartureAPI from '$lib/RestAPI/arrivalsAndDeparturesForStop.js'; | ||
|
||
export async function load({ params }) { | ||
const stopID = params.stopID; | ||
const stopResponse = await stopAPI(stopID); | ||
const stopBody = await stopResponse.json(); | ||
const arrivalsAndDeparturesResponse = await arrivalDepartureAPI(stopID) | ||
const arrivalsAndDeparturesResponseJSON = await arrivalsAndDeparturesResponse.json(); | ||
|
||
return { | ||
stopID: params.stopID, | ||
stopData: stopBody.data, | ||
arrivalsAndDeparturesResponse: arrivalsAndDeparturesResponseJSON | ||
} | ||
} |
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,10 @@ | ||
<script> | ||
import StopPane from '$components/oba/StopPane.svelte'; | ||
export let data; | ||
const stop = data.stopData.entry; | ||
const arrivalsAndDeparturesResponse = data.arrivalsAndDeparturesResponse; | ||
</script> | ||
|
||
<div class='pt-20 px-8 max-w-5xl mx-auto'> | ||
<StopPane {stop} {arrivalsAndDeparturesResponse} /> | ||
</div> |
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