Skip to content

Commit ad007b7

Browse files
authored
Refactor API to a separate app, add v0 (#2245)
* Refactor API to a separate app, add v0 * Add v0 migration files * Set v0 version
1 parent 14ac14b commit ad007b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+279
-113
lines changed

backend/apps/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""OWASP API."""

backend/apps/api/admin/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .api_key import ApiKeyAdmin

backend/apps/nest/admin/api_key.py renamed to backend/apps/api/admin/api_key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
"""Nest app APIKey model admin."""
1+
"""API key model admin."""
22

33
from django.contrib import admin
44

5-
from apps.nest.models.api_key import ApiKey
5+
from apps.api.models.api_key import ApiKey
66

77

88
class ApiKeyAdmin(admin.ModelAdmin):

backend/apps/api/apps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""API app config."""
2+
3+
from django.apps import AppConfig
4+
5+
6+
class ApiConfig(AppConfig):
7+
"""API app config."""
8+
9+
name = "apps.api"
File renamed without changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""API app mutations."""
2+
3+
import strawberry
4+
5+
from .api_key import ApiKeyMutations
6+
7+
8+
@strawberry.type
9+
class ApiMutations(ApiKeyMutations):
10+
"""API mutations."""

backend/apps/nest/api/internal/mutations/api_key.py renamed to backend/apps/api/internal/mutations/api_key.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Nest API key api.internal Mutations."""
1+
"""API app mutations."""
22

33
import logging
44
from datetime import datetime
@@ -9,9 +9,9 @@
99
from django.utils import timezone
1010
from strawberry.types import Info
1111

12-
from apps.nest.api.internal.nodes.api_key import ApiKeyNode
12+
from apps.api.internal.nodes.api_key import ApiKeyNode
13+
from apps.api.models.api_key import MAX_ACTIVE_KEYS, MAX_WORD_LENGTH, ApiKey
1314
from apps.nest.api.internal.permissions import IsAuthenticated
14-
from apps.nest.models.api_key import MAX_ACTIVE_KEYS, MAX_WORD_LENGTH, ApiKey
1515

1616
logger = logging.getLogger(__name__)
1717

@@ -38,7 +38,7 @@ class CreateApiKeyResult:
3838

3939
@strawberry.type
4040
class ApiKeyMutations:
41-
"""api.internal mutation class for API keys."""
41+
"""API key mutations."""
4242

4343
@strawberry.mutation(permission_classes=[IsAuthenticated])
4444
def create_api_key(self, info: Info, name: str, expires_at: datetime) -> CreateApiKeyResult:
File renamed without changes.

backend/apps/nest/api/internal/nodes/api_key.py renamed to backend/apps/api/internal/nodes/api_key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import strawberry
44
import strawberry_django
55

6-
from apps.nest.models.api_key import ApiKey
6+
from apps.api.models.api_key import ApiKey
77

88

99
@strawberry_django.type(

backend/apps/nest/api/internal/queries/__init__.py renamed to backend/apps/api/internal/queries/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import strawberry
22

3-
from apps.nest.api.internal.queries.api_key import ApiKeyQueries
3+
from apps.api.internal.queries.api_key import ApiKeyQueries
44

55

66
@strawberry.type

0 commit comments

Comments
 (0)