Skip to content

Commit

Permalink
refactor!: split router/services
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Nov 1, 2023
1 parent 868ccc3 commit 55ceb4e
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/sql_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sqlite3
import typing

from oauth.dto.user_dto import UserDto
from service.oauth.dto.user_dto import UserDto


def env(key):
Expand Down
7 changes: 2 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
from fastapi import FastAPI

from core.sql_util import check_and_create_table
from oauth import auth
from routers import deepl, location
from service.subway import subway
from service.summary import summary
from routers import deepl, location, subway, summary, weather, auth

# from service.summary.nlp_util import update_nlp_client
from service.weather import weather

app = FastAPI()

Expand Down
4 changes: 2 additions & 2 deletions oauth/auth.py → routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from core import sql_util
from core.response import Response, ResponseStatus
from oauth.account_util import calculate_jwt, encode_pw, validate_pw, validate_id, validate_jwt
from oauth.dto.return_code import IdValidateCode, PWValidateCode, JWTValidateCode
from service.oauth.account_util import calculate_jwt, encode_pw, validate_pw, validate_id, validate_jwt
from service.oauth.dto.return_code import IdValidateCode, PWValidateCode, JWTValidateCode

router = APIRouter()

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions oauth/account_util.py → service/oauth/account_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import jwt

from core import sql_util
from oauth.dto.return_code import (
from service.oauth.dto.return_code import (
IdValidateCode as IdValid,
PWValidateCode as PwValid,
JWTValidateCode as JWTValid
)
from oauth.rule.id_rule import ALLOWED_CHAR_RE
from service.oauth.rule.id_rule import ALLOWED_CHAR_RE

_SALT = os.environ.get("AIT_PW_SALT") # admin only
_PEPPER = os.environ.get("AIT_PW_PEPPER") # admin only


# noinspection DuplicatedCode
def validate_id(_id: str) -> IdValid:
from oauth.rule.id_rule import (
from service.oauth.rule.id_rule import (
MAX_LENGTH, MIN_LENGTH,
MIN_CHAR_LEN, MIN_NUMBER_LEN,
MAX_REPEAT_TIME
Expand Down Expand Up @@ -48,7 +48,7 @@ def validate_id(_id: str) -> IdValid:

# noinspection DuplicatedCode
def validate_pw(_id: str, pw: str) -> PwValid:
from oauth.rule.pw_rule import (
from service.oauth.rule.pw_rule import (
MAX_LENGTH, MIN_LENGTH,
MIN_CHAR_LEN, MIN_NUMBER_LEN,
MAX_REPEAT_TIME, MAX_ID_SIMILARITY
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from oauth import account_util
from oauth.dto.return_code import IdValidateCode
from oauth.rule import id_rule
from service.oauth import account_util
from service.oauth.dto.return_code import IdValidateCode
from service.oauth.rule import id_rule


def test_is_include_not_allowed_char():
Expand Down

0 comments on commit 55ceb4e

Please sign in to comment.