Bindu icon indicating copy to clipboard operation
Bindu copied to clipboard

Move Server Hook Code Out of Build-Time Path

Open Suvam-paul145 opened this issue 8 months ago β€’ 0 comments


πŸš€ Overview

This PR refactors the server hook logic by removing build-time guarded code and relocating it to the appropriate SvelteKit server lifecycle hook.

Previously, the logic in hooks.server.ts relied on a building flag to prevent execution during build time. This approach is not ideal and was marked with a TODO for improvement.


πŸ” What’s Changed

  • βœ… Identified the correct SvelteKit server lifecycle hook for runtime execution
  • βœ… Moved server-start logic out of the build-time guarded block
  • βœ… Removed dependency on the building flag
  • βœ… Cleaned up and simplified hooks.server.ts

πŸ“‚ Files Modified

  • frontend/src/hooks.server.ts (around line 42)

🧠 Why This Matters

  • Ensures proper separation between build-time and runtime logic
  • Aligns with SvelteKit best practices
  • Improves maintainability and readability of server hooks
  • Prevents unintended execution during build phase

πŸ§ͺ Testing

  • Verified server starts correctly without build-time execution
  • Confirmed no regression in existing functionality

πŸ™Œ Request

Kindly review and assign this issue to me if everything looks good. Happy to make any changes if needed!


πŸ“Ž Notes

If there are additional lifecycle hooks or patterns preferred in this project, please let me know for alignment.

Closes #347

Suvam-paul145 avatar Mar 27 '26 18:03 Suvam-paul145