-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves the previous config reader middleware (which loads metadata) to be dynamically lazyloaded when needed
- Loading branch information
1 parent
c92e08d
commit 8753d0b
Showing
4 changed files
with
35 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Config from "./config.js"; | ||
import axios, { AxiosResponse } from "axios"; | ||
|
||
interface MetadataFormat { | ||
androidVersion: string; | ||
iosVersion: string; | ||
} | ||
|
||
export default class Metadata { | ||
private static metadata: MetadataFormat | undefined = undefined; | ||
|
||
static async load<T extends keyof MetadataFormat>(key: T): Promise<MetadataFormat[T]> { | ||
if (this.metadata) { | ||
return this.metadata[key]; | ||
} | ||
|
||
const response: AxiosResponse = await axios.get(Config.METADATA_URL); | ||
const loaded: MetadataFormat = response.data as MetadataFormat; | ||
|
||
if (!loaded) { | ||
return Promise.reject("InvalidConfigFormat"); | ||
} | ||
|
||
this.metadata = loaded; | ||
|
||
console.log(this.metadata); | ||
|
||
return this.metadata[key]; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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