kop narsalar qoshildi
This commit is contained in:
2
config/conf/__init__.py
Normal file
2
config/conf/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .rest_framework import *
|
||||
from .simple_jwt import *
|
||||
7
config/conf/rest_framework.py
Normal file
7
config/conf/rest_framework.py
Normal file
@@ -0,0 +1,7 @@
|
||||
REST_FRAMEWORK = {
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": [
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
'rest_framework.authentication.BasicAuthentication',
|
||||
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||
],
|
||||
}
|
||||
10
config/conf/simple_jwt.py
Normal file
10
config/conf/simple_jwt.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
SIMPLE_JWT = {
|
||||
"ACCESS_TOKEN_LIFETIME": timedelta(days=10),
|
||||
"REFRESH_TOKEN_LIFETIME": timedelta(days=365),
|
||||
"ROTATE_REFRESH_TOKENS": True,
|
||||
"BLACKLIST_AFTER_ROTATION": True,
|
||||
"UPDATE_LAST_LOGIN": True,
|
||||
}
|
||||
3
config/env.py
Normal file
3
config/env.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from environ import Env
|
||||
|
||||
env = Env()
|
||||
@@ -1,11 +1,13 @@
|
||||
from pathlib import Path
|
||||
|
||||
from config.env import env
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||
env.read_env(BASE_DIR / '.env')
|
||||
|
||||
|
||||
SECRET_KEY = 'django-insecure-*44juz^a(752$j#8m7=w45$7fmi_z-t3e9v8kiojqay)b((gp3'
|
||||
DEBUG = True
|
||||
ALLOWED_HOSTS = []
|
||||
SECRET_KEY = env.str('SECRET_KEY')
|
||||
DEBUG = env.bool('DEBUG')
|
||||
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
|
||||
|
||||
|
||||
INSTALLED_APPS = [
|
||||
@@ -15,6 +17,15 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# packages
|
||||
'drf_yasg',
|
||||
'rest_framework',
|
||||
'rest_framework_simplejwt',
|
||||
|
||||
# local apps
|
||||
'core.apps.shared',
|
||||
'core.apps.authentication',
|
||||
'core.apps.accounts',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -25,6 +36,7 @@ MIDDLEWARE = [
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'core.apps.shared.middlewares.response_time.ResponseTimeMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
@@ -50,11 +62,11 @@ WSGI_APPLICATION = 'config.wsgi.application'
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'meridyn_pharma_db',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': '20090912',
|
||||
'HOST': 'db',
|
||||
'PORT': '5432',
|
||||
'NAME': env.str('POSTGRES_DB'),
|
||||
'USER': env.str('POSTGRES_USER'),
|
||||
'PASSWORD': env.str('POSTGRES_PASSWORD'),
|
||||
'HOST': env.str('POSTGRES_HOST'),
|
||||
'PORT': env.str('POSTGRES_PORT'),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +104,5 @@ MEDIA_ROOT = BASE_DIR / 'resources/media'
|
||||
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
AUTH_USER_MODEL = 'accounts.User'
|
||||
@@ -1,8 +1,23 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
from drf_yasg.views import get_schema_view
|
||||
from drf_yasg import openapi
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(
|
||||
title="Snippets API",
|
||||
default_version='v1',
|
||||
description="Test description",
|
||||
terms_of_service="https://www.google.com/policies/terms/",
|
||||
contact=openapi.Contact(email="contact@snippets.local"),
|
||||
license=openapi.License(name="BSD License"),
|
||||
),
|
||||
public=True,
|
||||
)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
@@ -10,3 +25,20 @@ urlpatterns = [
|
||||
|
||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
|
||||
urlpatterns += [
|
||||
path('swagger<format>/', schema_view.without_ui(cache_timeout=0), name='schema-json'),
|
||||
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
||||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
|
||||
]
|
||||
|
||||
urlpatterns += [
|
||||
path('api/v1/', include(
|
||||
[
|
||||
path('accounts/', include('core.apps.accounts.urls')),
|
||||
path('authentication/', include('core.apps.authentication.urls')),
|
||||
path('shared/', include('core.apps.shared.urls')),
|
||||
],
|
||||
)),
|
||||
]
|
||||
Reference in New Issue
Block a user