move some parts to services and introduce the backend communication for the airports
This commit is contained in:
15
src/services/airport.ts
Normal file
15
src/services/airport.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import axios from 'axios';
|
||||
import { Configuration } from './configuration';
|
||||
import { AirportOverview } from '../types';
|
||||
|
||||
export class Airport {
|
||||
static async all(): Promise<AirportOverview[]> {
|
||||
return axios
|
||||
.get<AirportOverview[]>(`${Configuration.resourceServer}/airport/all`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${sessionStorage.getItem('token')}`,
|
||||
},
|
||||
})
|
||||
.then((response) => response.data);
|
||||
}
|
||||
}
|
||||
7
src/services/configuration.ts
Normal file
7
src/services/configuration.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const Configuration = {
|
||||
resourceServer: process.env.RESOURCE_SERVER || 'http://localhost:3000',
|
||||
vatsim: {
|
||||
authorizeUrl: process.env.VATSIM_AUTH_URL || 'https://auth-dev.vatsim.net/oauth/authorize',
|
||||
clientId: process.env.VATSIM_CLIENT_ID || '461',
|
||||
},
|
||||
};
|
||||
4
src/services/index.ts
Normal file
4
src/services/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Airport } from "./airport";
|
||||
import { Configuration } from "./configuration";
|
||||
|
||||
export { Airport, Configuration };
|
||||
Reference in New Issue
Block a user