import os
from datetime import timedelta


class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY')
    FLASK_APP = os.environ.get('FLASK_APP')
    DEBUG = True
    TESTING = False

    SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY')
    JWT_TOKEN_LOCATION = ['cookies']
    JWT_ACCESS_COOKIE_PATH = '/api/'
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(minutes=15)
    JWT_SESSION_COOKIE = False
    JWT_COOKIE_SECURE = False
    JWT_COOKIE_CSRF_PROTECT = True

    REDIS_URL = os.environ.get('REDIS_URL')


class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get(
        'DATABASE_URL').replace('postgres://', 'postgresql://')
    FLASK_ENV = 'production'
    JWT_COOKIE_SECURE = True
    DEBUG = False


class DevelopmentConfig(Config):
    FLASK_ENV = 'development'
    DEBUG = True


class TestingConfig(Config):
    SQLALCHEMY_DATABASE_URI = 'sqlite://'
    TESTING = True


configs = {
           'Config': Config,
           'ProductionConfig': ProductionConfig,
           'DevelopmentConfig': DevelopmentConfig,
           'TestingConfig': TestingConfig
           }

import os
from datetime import timedelta


class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY')
    FLASK_APP = os.environ.get('FLASK_APP')
    DEBUG = True
    TESTING = False

    SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY')
    JWT_TOKEN_LOCATION = ['cookies']
    JWT_ACCESS_COOKIE_PATH = '/api/'
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(minutes=15)
    JWT_SESSION_COOKIE = False
    JWT_COOKIE_SECURE = False
    JWT_COOKIE_CSRF_PROTECT = True

    REDIS_URL = os.environ.get('REDIS_URL')


class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get(
        'DATABASE_URL').replace('postgres://', 'postgresql://')
    FLASK_ENV = 'production'
    JWT_COOKIE_SECURE = True
    DEBUG = False


class DevelopmentConfig(Config):
    FLASK_ENV = 'development'
    DEBUG = True


class TestingConfig(Config):
    SQLALCHEMY_DATABASE_URI = 'sqlite://'
    TESTING = True


configs = {
           'Config': Config,
           'ProductionConfig': ProductionConfig,
           'DevelopmentConfig': DevelopmentConfig,
           'TestingConfig': TestingConfig
           }
