-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from samudradev/refactor-api
♻️ REFACTOR: API Cleanup
- Loading branch information
Showing
17 changed files
with
396 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ jobs: | |
poetry install | ||
- name: Test with pytest | ||
run: | | ||
poetry run pytest --verbose | ||
poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "samudra" | ||
version = "0.6.0" | ||
version = "0.7.0" | ||
description = "" | ||
authors = ["Thaza_Kun <[email protected]>"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
anyio==3.6.1 ; python_version >= "3.8" and python_version < "4.0" | ||
bcrypt==3.2.2 ; python_version >= "3.8" and python_version < "4.0" | ||
certifi==2022.9.24 ; python_version >= "3.8" and python_version < "4" | ||
cffi==1.15.1 ; python_version >= "3.8" and python_version < "4.0" | ||
charset-normalizer==2.1.1 ; python_version >= "3.8" and python_version < "4" | ||
click==8.1.3 ; python_version >= "3.8" and python_version < "4.0" | ||
colorama==0.4.5 ; python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows" | ||
cryptography==37.0.4 ; python_version >= "3.8" and python_version < "4.0" | ||
ecdsa==0.18.0 ; python_version >= "3.8" and python_version < "4.0" | ||
et-xmlfile==1.1.0 ; python_version >= "3.8" and python_version < "4.0" | ||
fastapi==0.79.1 ; python_version >= "3.8" and python_version < "4.0" | ||
h11==0.14.0 ; python_version >= "3.8" and python_version < "4.0" | ||
idna==3.4 ; python_version >= "3.8" and python_version < "4" | ||
numpy==1.23.3 ; python_version >= "3.8" and python_version < "4.0" | ||
openpyxl==3.0.10 ; python_version >= "3.8" and python_version < "4.0" | ||
pandas==1.5.0 ; python_version >= "3.8" and python_version < "4.0" | ||
passlib==1.7.4 ; python_version >= "3.8" and python_version < "4.0" | ||
peewee==3.15.3 ; python_version >= "3.8" and python_version < "4.0" | ||
pyasn1==0.4.8 ; python_version >= "3.8" and python_version < "4.0" | ||
pycparser==2.21 ; python_version >= "3.8" and python_version < "4.0" | ||
pycryptodome==3.15.0 ; python_version >= "3.8" and python_version < "4.0" | ||
pydantic==1.10.2 ; python_version >= "3.8" and python_version < "4.0" | ||
pymysql==1.0.2 ; python_version >= "3.8" and python_version < "4.0" | ||
python-dateutil==2.8.2 ; python_version >= "3.8" and python_version < "4.0" | ||
python-dotenv==0.20.0 ; python_version >= "3.8" and python_version < "4.0" | ||
python-jose==3.3.0 ; python_version >= "3.8" and python_version < "4.0" | ||
python-multipart==0.0.5 ; python_version >= "3.8" and python_version < "4.0" | ||
pytomlpp==1.0.11 ; python_version >= "3.8" and python_version < "4.0" | ||
pytz==2022.2.1 ; python_version >= "3.8" and python_version < "4.0" | ||
requests==2.28.1 ; python_version >= "3.8" and python_version < "4" | ||
rsa==4.9 ; python_version >= "3.8" and python_version < "4" | ||
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0" | ||
sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4.0" | ||
starlette==0.19.1 ; python_version >= "3.8" and python_version < "4.0" | ||
typing-extensions==4.3.0 ; python_version >= "3.8" and python_version < "4.0" | ||
urllib3==1.26.12 ; python_version >= "3.8" and python_version < "4" | ||
uvicorn==0.18.3 ; python_version >= "3.8" and python_version < "4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import List, Optional | ||
|
||
import pydantic as pyd | ||
|
||
|
||
class QueryFilter(pyd.BaseModel): | ||
limit: Optional[int] | ||
cakupan: Optional[List[str]] | ||
kata_asing: Optional[List[str]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .routes import lemmas, authentication | ||
from .routes import lemmas, auth, golongan_kata |
35 changes: 8 additions & 27 deletions
35
samudra/server/routes/authentication.py → samudra/server/routes/auth.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from datetime import timedelta, datetime | ||
from typing import Optional | ||
|
||
from jose import jwt | ||
from pydantic import BaseModel | ||
|
||
SECRET_KEY = os.getenv("SECRET_KEY") | ||
ALGORITHM = os.getenv("ALGORITHM") | ||
ACCESS_TOKEN_EXPIRE_MINUTES = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES")) | ||
|
||
|
||
class PenggunaCreateDTO(BaseModel): | ||
nama: str | ||
katalaluan: str | ||
|
||
|
||
def create_access_token(data: dict, expires_delta: Optional[timedelta]): | ||
to_encode = data.copy() | ||
if expires_delta: | ||
expire = datetime.utcnow() + expires_delta | ||
else: | ||
expire = datetime.utcnow() + timedelta(minutes=15) | ||
to_encode.update({"exp": expire}) | ||
encoded_jwt = jwt.encode(to_encode, SECRET_KEY) | ||
return encoded_jwt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.