Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/gemstack/project/scaffolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def _scaffold_ts_route(self, route_path: str) -> Path:
route_file,
f"// Route handler for {route_path}\n\n"
f"export async function handle(req: Request): Promise<Response> {{\n"
f" // TODO: Implement {route_path}\n"
f' return new Response(JSON.stringify({{ status: "ok" }}));\n'
f' return Response.json({{ status: "ok", path: "{route_path}" }});\n'
f"}}\n",
)
return route_file
Expand Down
16 changes: 16 additions & 0 deletions tests/test_scaffold_ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Tests for TypeScript scaffolding."""

from pathlib import Path
from gemstack.project.scaffolder import Scaffolder

class TestTypeScriptScaffolding:
def test_scaffold_route_creates_files(self, tmp_path: Path) -> None:
route_path = "/api/v1/users"
Scaffolder(tmp_path)._scaffold_ts_route(route_path)

route_file = tmp_path / "src" / "routes" / "api-v1-users.ts"
assert route_file.exists()
content = route_file.read_text()
assert "export async function handle(req: Request): Promise<Response>" in content
assert f'return Response.json({{ status: "ok", path: "{route_path}" }});' in content
assert "TODO" not in content
Loading