Skip to content

Commit

Permalink
feat(user): 기본 post 회원가입 구현 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
middlefitting authored Jan 24, 2024
1 parent 83b24fe commit 6af19bd
Show file tree
Hide file tree
Showing 51 changed files with 8,370 additions and 4 deletions.
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ venv/
ENV/
env.bak/
venv.bak/
*/.venv

# Spyder project settings
.spyderproject
Expand Down
48 changes: 46 additions & 2 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'user',
'rest_framework_simplejwt',
'rest_framework_docs',
'drf_yasg'
]

MIDDLEWARE = [
Expand All @@ -54,7 +59,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')], # Add this line
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
Expand All @@ -76,7 +81,7 @@
'default': {
'ENGINE': os.environ.get('SQL_ENGINE', "django.db.backends.sqlite3"),
'NAME': os.environ.get('SQL_DATABASE', BASE_DIR / "db.sqlite3"),
'USER': os.environ.get('SQL_USER', 'user'),
'USER': os.environ.get('SQL_USER', '../user'),
'PASSWORD': os.environ.get('SQL_PASSWORD', 'password'),
'HOST': os.environ.get('SQL_HOST', 'localhost'),
'PORT': os.environ.get('SQL_PORT', '5432'),
Expand Down Expand Up @@ -122,3 +127,42 @@

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],

'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
],

'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
],

'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.JSONParser',
],

'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['console'],
},
},
}

AUTH_USER_MODEL = 'user.User'
32 changes: 31 additions & 1 deletion backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,38 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
from rest_framework import routers, permissions

from drf_yasg.views import get_schema_view
from drf_yasg import openapi


from user import views

schema_view = get_schema_view(
openapi.Info(
title="My Project API",
default_version="v1",

description="API documentation for My Project",
terms_of_service="https://www.example.com/terms/",
contact=openapi.Contact(email="[email protected]"), license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)


router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)

urlpatterns = [
path('api/', include(router.urls)),
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path('docs/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]

# urlpatterns += router.urls
11 changes: 11 additions & 0 deletions backend/backend/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import AllowAny
from rest_framework.response import Response


@api_view(['GET', 'POST'])
@permission_classes([AllowAny])
def hello_rest_api(request):
data = {'message': 'Hello REST API'}
return Response(data)

6 changes: 5 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
Django==4.2.9
psycopg2==2.9.3
psycopg2==2.9.3
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.1
django-rest-framework-docs==0.1.7
drf-yasg==1.21.7
18 changes: 18 additions & 0 deletions backend/static/drf_yasg/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Information about external resources

The following files are taken from external resources or trees.

Files: insQ.js
insQ.min.js
License: MIT
Copyright: Zbyszek Tenerowicz
Eryk Napierała <[email protected]>
Askar Yusupov <[email protected]>
Dan Dascalescu <[email protected]>
Source: https://github.com/naugtur/insertionQuery v1.0.3

Files: immutable.js
immutable.min.js
License: MIT
Copyright: 2014-present, Facebook, Inc
Source: https://github.com/immutable-js/immutable-js/releases/tag/v3.8.2
Loading

0 comments on commit 6af19bd

Please sign in to comment.