Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7278b26

Browse files
added config settings for initializing gateway
1 parent 44106de commit 7278b26

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

‎src/config/config.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import functools
2-
from pydantic import BaseSettings, Field
2+
from pydantic import BaseSettings, Field, AnyHttpUrl, EmailStr
33

44

55
class DatabaseSettings(BaseSettings):
@@ -98,6 +98,32 @@ class Config:
9898
env_file_encoding = 'utf-8'
9999

100100

101+
class AppSettings(BaseSettings):
102+
app_name: str = "EOD-STOCK-API - API GATEWAY"
103+
app_description: str = """
104+
**Stock Marketing & Financial News API**,
105+
106+
provides end-of-day stock information for multiple exchanges around the world.
107+
With this API, you can retrieve data for a specific stock at a given date, or for a range of dates. and also get access
108+
to companies fundamental data, financial statements, social media trending stocks by sentiment, and also the ability to create a summary of the Financial
109+
News Related to a certain stock or company and its sentiment.
110+
"""
111+
version: str = "1.0.0"
112+
terms_of_service: AnyHttpUrl = "https://eod-stock-api.site/terms"
113+
contact_name: str = "EOD-STOCK-API"
114+
contact_url: AnyHttpUrl = "https://eod-stock-api.site/contact"
115+
contact_email: EmailStr = "info@eod-stock-api.site"
116+
license_name: str = "Apache 2.0"
117+
license_url: AnyHttpUrl = "https://www.apache.org/licenses/LICENSE-2.0.html"
118+
docs_url: str = None
119+
openapi_url: str = None
120+
redoc_url: str = None
121+
122+
class Config:
123+
env_file = '.env.development'
124+
env_file_encoding = 'utf-8'
125+
126+
101127
class Settings(BaseSettings):
102128
SECRET_KEY: str = Field(..., env="SECRET_TOKEN")
103129
DATABASE_SETTINGS: DatabaseSettings = DatabaseSettings()
@@ -112,6 +138,7 @@ class Settings(BaseSettings):
112138
PAYPAL_SETTINGS: PayPalSettings = PayPalSettings()
113139
CLOUDFLARE_SETTINGS: CloudflareSettings = CloudflareSettings()
114140
FERNET_KEY: bytes = Field(..., env="FERNET_KEY")
141+
APP_SETTINGS: AppSettings = AppSettings()
115142

116143
class Config:
117144
case_sensitive = True

‎src/main/main.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,25 @@
3535

3636
cf_firewall = EODAPIFirewall()
3737
# API Servers
38-
# TODO NOTE will add more Server URLS Later
39-
# TODO just use a server list straight from config
4038
api_server_urls = config_instance().API_SERVERS.SERVERS_LIST.split(',')
4139
api_server_counter = 0
4240

4341
# used to logging debug information for the application
4442
app_logger = init_logger("eod_stock_api_gateway")
4543

46-
description = """
47-
**Stock Marketing & Financial News API**,
48-
49-
provides end-of-day stock information for multiple exchanges around the world.
50-
With this API, you can retrieve data for a specific stock at a given date, or for a range of dates. and also get access
51-
to companies fundamental data, financial statements, social media trending stocks by sentiment, and also the ability to create a summary of the Financial
52-
News Related to a certain stock or company and its sentiment.
53-
"""
54-
5544
app = FastAPI(
56-
title="EOD-STOCK-API - API GATEWAY",
57-
description=description,
58-
version="1.0.0",
59-
terms_of_service="https://eod-stock-api.site/terms",
45+
title=config_instance().APP_SETTINGS.app_name,
46+
description=config_instance().APP_SETTINGS.app_description,
47+
version=config_instance().APP_SETTINGS.version,
48+
terms_of_service=config_instance().APP_SETTINGS.terms_of_service,
6049
contact={
61-
"name": "EOD-STOCK-API",
62-
"url": "https://eod-stock-api.site/contact",
63-
"email": "info@eod-stock-api.site"
50+
"name": config_instance().APP_SETTINGS.contact_name,
51+
"url": config_instance().APP_SETTINGS.contact_url,
52+
"email": config_instance().APP_SETTINGS.contact_email
6453
},
6554
license_info={
66-
"name": "Apache 2.0",
67-
"url": "https://www.apache.org/licenses/LICENSE-2.0.html",
55+
"name": config_instance().APP_SETTINGS.license_name,
56+
"url": config_instance().APP_SETTINGS.license_url,
6857
},
6958
docs_url=None,
7059
openapi_url=None,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /