Skip to content

Commit 0613d3b

Browse files
fix: docomments and endpoint constants
Update avwx.tsx
1 parent a399077 commit 0613d3b

File tree

11 files changed

+27
-30
lines changed

11 files changed

+27
-30
lines changed

examples/playground/src/components/map/avwx.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const Avwx = memo(() => {
3030
const layers = useQueries({
3131
queries: sources.map(source => ({
3232
queryKey: ["avwx", source],
33-
queryFn: async () => [source, await weatherApi.getAvwxReports([source])] as const,
33+
queryFn: async () => [source, await weatherApi.getAviationWeatherReports([source])] as const,
3434
})),
3535
})
3636

packages/weather/src/api/avwx/getAvwxReports.ts renamed to packages/weather/src/api/avwx/getAviationWeatherReports.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { FeatureCollection, Geometry } from "geojson"
4-
import { getAvwxApiRoot } from "../../constants"
4+
import { getWeatherApiRoot } from "../../constants"
55
import { AVWXSource, AVWXSourceProperties } from "../types"
66

77
/**
8-
* Queries GeoJSON data for all AVWX reports currently available from the selected sources
9-
* @param sources - List of sources to from which to load AVWX reports from
8+
* Queries GeoJSON data for all aviation weather reports currently available from the selected sources
9+
* @param sources - List of sources to from which to load the reports from
1010
* @returns A GEOJson feature collection containing the reports
1111
*/
12-
export default async function getAvwxReports<S extends AVWXSource>(sources: S[]) {
12+
export default async function getAviationWeatherReports<S extends AVWXSource>(sources: S[]) {
1313
const result = await navigraphRequest
14-
.get<FeatureCollection<Geometry, AVWXSourceProperties[S]>>(`${getAvwxApiRoot()}/combined`, {
14+
.get<FeatureCollection<Geometry, AVWXSourceProperties[S]>>(`${getWeatherApiRoot()}/avwx/combined`, {
1515
params: { sources: sources.join(",") },
1616
})
1717
.catch((e: unknown) => Logger.err("Failed to AVWX reports. Reason:", isAxiosError(e) ? e.message : e))

packages/weather/src/api/getReportsAlongRoute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { Position } from "geojson"
4-
import { getRouteApiRoot } from "../constants"
4+
import { getWeatherApiRoot } from "../constants"
55
import { Metar, Taf } from "./types"
66

77
/**
@@ -18,7 +18,7 @@ export default async function getReportsAlongRoute<T extends "metar" | "taf">(
1818
type ReportType = T extends "metar" ? Metar : T extends "taf" ? Taf : never
1919

2020
const result = await navigraphRequest
21-
.get<ReportType[]>(getRouteApiRoot(), {
21+
.get<ReportType[]>(`${getWeatherApiRoot()}/route`, {
2222
params: {
2323
path: path.map(position => position.join(",")).join(";"),
2424
type,

packages/weather/src/api/metar/getMetarAtAirport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
3-
import { getMetarApiRoot } from "../../constants"
3+
import { getWeatherApiRoot } from "../../constants"
44
import { Metar } from "../types"
55

66
/**
@@ -10,7 +10,7 @@ import { Metar } from "../types"
1010
*/
1111
export default async function getMetarAtAirport(icao: string) {
1212
const result = await navigraphRequest
13-
.get<Metar>(`${getMetarApiRoot()}/${icao}`)
13+
.get<Metar>(`${getWeatherApiRoot()}/metar/${icao}`)
1414
.catch((e: unknown) => Logger.err(`Failed to fetch METAR for ${icao}. Reason:`, isAxiosError(e) ? e.message : e))
1515

1616
return result?.data || null

packages/weather/src/api/metar/getMetarsAroundPoint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
3-
import { getMetarApiRoot } from "../../constants"
3+
import { getWeatherApiRoot } from "../../constants"
44
import { Metar } from "../types"
55

66
/**
7-
* Queries all METARs within a distance of a point issued within approximately the last 10 hours, ordered by distance from the center point
7+
* Queries all METARs within a distance of a point issued within approximately the last 10 hours, ordered from most recent to most outdated, then by distance from the center point
88
* @param latitude - Latitude of the center point
99
* @param longitude - longitude of the center point
1010
* @param radius - Radius in **nautical miles** around the center point to search for METARs within
@@ -18,7 +18,7 @@ export default async function getMetarsAroundPoint(
1818
limit?: number,
1919
) {
2020
const result = await navigraphRequest
21-
.get<Metar[]>(`${getMetarApiRoot()}/around/${latitude}/${longitude}`, {
21+
.get<Metar[]>(`${getWeatherApiRoot()}/metar/around/${latitude}/${longitude}`, {
2222
params: {
2323
radius,
2424
limit,

packages/weather/src/api/metar/getMetarsAtAirport.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
3-
import { getMetarApiRoot } from "../../constants"
3+
import { getWeatherApiRoot } from "../../constants"
44
import { Metar } from "../types"
55

66
/**
7-
* Queries all METARs for an airport issued within approximately the last 10 hours
7+
* Queries all METARs for an airport issued within approximately the last 10 hours, ordered from most recent to most outdated
88
* @param icao - The ICAO code of the airport from which to load the METARs
99
* @returns - An array of METAR objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
1010
*/
1111
export default async function getMetarsAtAirport(icao: string) {
1212
const result = await navigraphRequest
13-
.get<Metar[]>(`${getMetarApiRoot()}/multi/${icao}`)
13+
.get<Metar[]>(`${getWeatherApiRoot()}/metar/multi/${icao}`)
1414
.catch((e: unknown) => Logger.err(`Failed to fetch METARs for ${icao}. Reason:`, isAxiosError(e) ? e.message : e))
1515

1616
return result?.data || null

packages/weather/src/api/taf/getTafAtAirport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
3-
import { getTafApiRoot } from "../../constants"
3+
import { getWeatherApiRoot } from "../../constants"
44
import { Taf } from "../types"
55

66
/**
@@ -10,7 +10,7 @@ import { Taf } from "../types"
1010
*/
1111
export default async function getTafAtAirport(icao: string) {
1212
const result = await navigraphRequest
13-
.get<Taf>(`${getTafApiRoot()}/${icao}`)
13+
.get<Taf>(`${getWeatherApiRoot()}/taf/${icao}`)
1414
.catch((e: unknown) => Logger.err(`Failed to fetch TAF for ${icao}. Reason:`, isAxiosError(e) ? e.message : e))
1515

1616
return result?.data || null

packages/weather/src/api/taf/getTafsAroundPoint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
3-
import { getTafApiRoot } from "../../constants"
3+
import { getWeatherApiRoot } from "../../constants"
44
import { Taf } from "../types"
55

66
/**
7-
* Queries all TAFs within a distance of a point issued within approximately the last 10 hours, ordered by distance from the center point
7+
* Queries all TAFs within a distance of a point issued within approximately the last 10 hours, ordered from most recent to most outdated, then by distance from the center point
88
* @param latitude - Latitude of the center point
99
* @param longitude - longitude of the center point
1010
* @param radius - Radius in **nautical miles** around the center point to search for TAFs within
@@ -13,7 +13,7 @@ import { Taf } from "../types"
1313
*/
1414
export default async function getTafsAroundPoint(latitude: number, longitude: number, radius?: number, limit?: number) {
1515
const result = await navigraphRequest
16-
.get<Taf[]>(`${getTafApiRoot()}/around/${latitude}/${longitude}`, {
16+
.get<Taf[]>(`${getWeatherApiRoot()}/taf/around/${latitude}/${longitude}`, {
1717
params: {
1818
radius,
1919
limit,

packages/weather/src/api/taf/getTafsAtAirport.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Logger } from "@navigraph/app"
22
import { isAxiosError, navigraphRequest } from "@navigraph/auth"
3-
import { getTafApiRoot } from "../../constants"
3+
import { getWeatherApiRoot } from "../../constants"
44
import { Taf } from "../types"
55

66
/**
7-
* Queries all TAFs for an airport issued within approximately the last 10 hours
7+
* Queries all TAFs for an airport issued within approximately the last 10 hours, ordered from most recent to most outdated
88
* @param icao - The ICAO code of the airport from which to load the TAFs
99
* @returns - An array of TAF objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
1010
*/
1111
export default async function getTafsAtAirport(icao: string) {
1212
const result = await navigraphRequest
13-
.get<Taf[]>(`${getTafApiRoot()}/multi/${icao}`)
13+
.get<Taf[]>(`${getWeatherApiRoot()}/taf/multi/${icao}`)
1414
.catch((e: unknown) => Logger.err(`Failed to fetch TAFs for ${icao}. Reason:`, isAxiosError(e) ? e.message : e))
1515

1616
return result?.data || null

packages/weather/src/constants.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
import { getDefaultAppDomain } from "@navigraph/app"
22

3-
export const getMetarApiRoot = () => `https://wx.api.${getDefaultAppDomain()}/v1/metar`
4-
export const getTafApiRoot = () => `https://wx.api.${getDefaultAppDomain()}/v1/taf`
5-
export const getRouteApiRoot = () => `https://wx.api.${getDefaultAppDomain()}/v1/route`
6-
export const getAvwxApiRoot = () => `https://wx.api.${getDefaultAppDomain()}/v1/avwx`
3+
export const getWeatherApiRoot = () => `https://wx.api.${getDefaultAppDomain()}/v1`

0 commit comments

Comments
 (0)