Compare commits
1 Commits
v3.0.0-dev
...
v3.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dd11f7b3b |
8
package-lock.json
generated
8
package-lock.json
generated
@@ -9,7 +9,7 @@
|
||||
"version": "3.0.0",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@owlboard/api-schema-types": "^3.0.3-alpha10",
|
||||
"@owlboard/api-schema-types": "^3.0.3-alpha17",
|
||||
"install": "^0.13.0",
|
||||
"latlon-geohash": "^2.0.0",
|
||||
"npm": "^11.13.0"
|
||||
@@ -506,9 +506,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@owlboard/api-schema-types": {
|
||||
"version": "3.0.3-alpha10",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fapi-schema-types/-/3.0.3-alpha10/api-schema-types-3.0.3-alpha10.tgz",
|
||||
"integrity": "sha512-gwQRhMXSgQYJVg6kc4sP9Dp2zCyubLLdS9Pxa4egED6XiAfG+YfCQZ4HRuGH9jEhp618Z93JyxAXiu7Iq2hBlw==",
|
||||
"version": "3.0.3-alpha17",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fapi-schema-types/-/3.0.3-alpha17/api-schema-types-3.0.3-alpha17.tgz",
|
||||
"integrity": "sha512-9jtsajZIq/1W9w1XPSIQSH/rcH2mfnS+3XoQpe81Yor2pOVl5+iyHZ9wAlJLrLEVKVVs3k4lkjcM5l6KgWgd9w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tsconfig/node10": {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"author": "Frederick Boniface",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@owlboard/api-schema-types": "^3.0.3-alpha10",
|
||||
"@owlboard/api-schema-types": "^3.0.3-alpha17",
|
||||
"install": "^0.13.0",
|
||||
"latlon-geohash": "^2.0.0",
|
||||
"npm": "^11.13.0"
|
||||
|
||||
@@ -9,3 +9,4 @@ export { PisModule } from './modules/pis.js';
|
||||
export { LocationFilterModule } from './modules/locationFilter.js';
|
||||
export { StationDataModule } from './modules/stationData.js';
|
||||
export { TrainsModule } from './modules/trains.js';
|
||||
export { BoardModule } from './modules/board.js';
|
||||
|
||||
@@ -3,12 +3,14 @@ import { PisModule } from "../modules/pis.js";
|
||||
import { LocationFilterModule } from "../modules/locationFilter.js";
|
||||
import { StationDataModule } from "../modules/stationData.js";
|
||||
import { TrainsModule } from "../modules/trains.js";
|
||||
import { BoardModule } from "../modules/board.js";
|
||||
|
||||
export class OwlBoardClient extends BaseClient {
|
||||
public readonly pis: PisModule;
|
||||
public readonly locationFilter: LocationFilterModule;
|
||||
public readonly stationData: StationDataModule;
|
||||
public readonly trains: TrainsModule;
|
||||
public readonly board: BoardModule
|
||||
|
||||
constructor(baseUrl: string, apiKey?: string) {
|
||||
super(baseUrl, apiKey);
|
||||
@@ -17,5 +19,6 @@ export class OwlBoardClient extends BaseClient {
|
||||
this.locationFilter = new LocationFilterModule(this);
|
||||
this.stationData = new StationDataModule(this);
|
||||
this.trains = new TrainsModule(this);
|
||||
this.board = new BoardModule(this);
|
||||
}
|
||||
}
|
||||
21
src/modules/board.ts
Normal file
21
src/modules/board.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ApiStationsBoard } from '@owlboard/api-schema-types';
|
||||
import type { BaseClient, ApiResult } from '../lib/base.js';
|
||||
import { IsValidCrs, IsValidTiploc } from '../lib/validation.js';
|
||||
import { ValidationError } from '../lib/errors.js';
|
||||
|
||||
export class BoardModule {
|
||||
constructor(private client: BaseClient) { }
|
||||
|
||||
async getByLocation(location: string, customFetch?: typeof fetch): Promise<ApiResult<ApiStationsBoard.StationsBoard>> {
|
||||
if (!IsValidCrs(location) && !IsValidTiploc(location)) {
|
||||
throw new ValidationError("Location", "Location must be provided as CRS or TIPLOC");
|
||||
}
|
||||
|
||||
const path = `/board/${location.toUpperCase()}`;
|
||||
|
||||
return this.client.request<ApiStationsBoard.StationsBoard>(path, {
|
||||
method: 'GET',
|
||||
}, customFetch);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user