aboutsummaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorFridon <[email protected]>2022-06-23 00:01:12 +0400
committerFridon <[email protected]>2022-06-23 00:01:12 +0400
commit7d72153d68ea4c682266f0301aa45b4e3a9e45a9 (patch)
treeba2b4b8937d0c7785a468fae18880762a5e6b484 /src/models
parentbe829dad070205555c514ff497fcf2eae355a6e2 (diff)
downloadcountryfetch-7d72153d68ea4c682266f0301aa45b4e3a9e45a9.tar.xz
countryfetch-7d72153d68ea4c682266f0301aa45b4e3a9e45a9.zip
big refactor + raw option
Diffstat (limited to 'src/models')
-rw-r--r--src/models/FetchedCountry.model.ts9
-rw-r--r--src/models/country.model.ts23
2 files changed, 26 insertions, 6 deletions
diff --git a/src/models/FetchedCountry.model.ts b/src/models/FetchedCountry.model.ts
new file mode 100644
index 0000000..be636ff
--- /dev/null
+++ b/src/models/FetchedCountry.model.ts
@@ -0,0 +1,9 @@
+export interface FetchedCountry {
+ country: string;
+ flag: string;
+ languages: string;
+ capital: string;
+ region: string;
+ population: number;
+ currencies: string;
+}
diff --git a/src/models/country.model.ts b/src/models/country.model.ts
index 4765d5e..1a6b3ae 100644
--- a/src/models/country.model.ts
+++ b/src/models/country.model.ts
@@ -1,9 +1,20 @@
// For better currency types, this can be used later:
// https://github.com/freeall/currency-codes
// Same can be done for language abbreviations
-export type CurrencyAbbr = string;
-export type CurrencyInfo = { name: string; symbol: string };
-export type LangAbbr = string;
+type CurrencyAbbr = string;
+type CurrencyInfo = { name: string; symbol: string };
+type LangAbbr = string;
+
+export type Currencies = Record<CurrencyAbbr, CurrencyInfo>;
+export type Languages = Record<LangAbbr, string>;
+export enum Region {
+ Asia = "Asia",
+ Europe = "Europe",
+ Americas = "Americas",
+ Africa = "Africa",
+ Oceania = "Oceania",
+ Antarctic = "Antarctic",
+}
export interface Country {
name: {
@@ -11,10 +22,10 @@ export interface Country {
official: string;
// Need type for nativeName later
};
- currencies: Record<CurrencyAbbr, CurrencyInfo>;
+ currencies: Currencies;
capital: string[];
flag: string;
population: number;
- languages: Record<LangAbbr, string>;
- region: string;
+ languages: Languages;
+ region: Region;
}