Skip to content

Commit 8a0abd7

Browse files
committed
refactor: standardize API endpoint paths and enhance datetime handling
- Updated API endpoint paths in pad, template pad, and user routers to remove trailing slashes for consistency. - Enhanced datetime handling in BackupService to include timezone information, improving accuracy in backup creation timing. - Adjusted frontend API calls to align with the updated endpoint structure, ensuring seamless integration across the application.
1 parent e69cb4e commit 8a0abd7

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/backend/database/service/backup_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import List, Optional, Dict, Any
66
from uuid import UUID
7-
from datetime import datetime
7+
from datetime import datetime, timezone
88

99
from sqlalchemy.ext.asyncio import AsyncSession
1010

@@ -149,8 +149,8 @@ async def create_backup_if_needed(self, source_id: UUID, data: Dict[str, Any],
149149
# Get the latest backup
150150
latest_backup = await self.repository.get_latest_by_source(source_id)
151151

152-
# Calculate the current time
153-
current_time = datetime.now()
152+
# Calculate the current time with timezone information
153+
current_time = datetime.now(timezone.utc)
154154

155155
# Determine if we need to create a backup
156156
create_backup = False

src/backend/routers/pad_router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
pad_router = APIRouter()
1111

1212

13-
@pad_router.post("/")
13+
@pad_router.post("")
1414
async def save_canvas(
1515
data: Dict[str, Any],
1616
user: UserSession = Depends(require_auth),
@@ -47,7 +47,7 @@ async def save_canvas(
4747
raise HTTPException(status_code=500, detail=f"Failed to save canvas data: {str(e)}")
4848

4949

50-
@pad_router.get("/")
50+
@pad_router.get("")
5151
async def get_canvas(
5252
user: UserSession = Depends(require_auth),
5353
pad_service: PadService = Depends(get_pad_service),

src/backend/routers/template_pad_router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
template_pad_router = APIRouter()
1010

1111

12-
@template_pad_router.post("/")
12+
@template_pad_router.post("")
1313
async def create_template_pad(
1414
data: Dict[str, Any],
1515
name: str,
@@ -29,7 +29,7 @@ async def create_template_pad(
2929
raise HTTPException(status_code=400, detail=str(e))
3030

3131

32-
@template_pad_router.get("/")
32+
@template_pad_router.get("")
3333
async def get_all_template_pads(
3434
_: bool = Depends(require_admin),
3535
template_pad_service: TemplatePadService = Depends(get_template_pad_service)

src/backend/routers/user_router.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
user_router = APIRouter()
1313

1414

15-
@user_router.post("/")
15+
@user_router.post("")
1616
async def create_user(
1717
user_id: UUID,
1818
username: str,
@@ -42,7 +42,7 @@ async def create_user(
4242
raise HTTPException(status_code=400, detail=str(e))
4343

4444

45-
@user_router.get("/")
45+
@user_router.get("")
4646
async def get_all_users(
4747
_: bool = Depends(require_admin),
4848
user_service: UserService = Depends(get_user_service)

src/frontend/src/api/hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const api = {
9797
// Canvas
9898
getCanvas: async (): Promise<CanvasData> => {
9999
try {
100-
const result = await fetchApi('/api/pad/');
100+
const result = await fetchApi('/api/pad');
101101
return result;
102102
} catch (error) {
103103
throw error;
@@ -106,7 +106,7 @@ export const api = {
106106

107107
saveCanvas: async (data: CanvasData): Promise<any> => {
108108
try {
109-
const result = await fetchApi('/api/pad/', {
109+
const result = await fetchApi('/api/pad', {
110110
method: 'POST',
111111
body: JSON.stringify(data),
112112
});

0 commit comments

Comments
 (0)