Setting up application constants and models

Next up, we will set up two folders in our src folder, where we will keep our application constants and the application models for our application. Since this is a  small demo application, we will keep all our models in one file and we will keep all application constants in one index.ts file as well. 

 

Constants 

// End points
export const CURRENCY_API_URL_ENDPOINT = 'http://localhost:3000/api/currency/';

export const NEWS_API_URL_ENDPOINT = 'http://localhost:3000/api/news/';

export const WEATHER_API_URL_ENDPOINT = 'http://localhost:3000/api/weather/';

 Models 

export interface NewsItem {
  source: string;
  author: string;
  title: string;
  description: string;
  url: string;
  urlToImage: string;
  publishedAt: Date;
  content: string;
}

interface Coord {
  lon: number;
  lat: number;
}

export interface Weather {
  coord: Coord;
  temp: number;
  feels_like: number;
  temp_min: number;
  temp_max: number;
  pressure: number;
  humidity: number;
  name: string;
}

export interface Currency {
  currency: string;
  value: number;
}