Refactor to monorepo architecture with NextJS App Router and TypeScript (Phase 1)#1
Conversation
Co-authored-by: mlynam <2816612+mlynam@users.noreply.github.com>
…nerabilities Co-authored-by: mlynam <2816612+mlynam@users.noreply.github.com>
Co-authored-by: mlynam <2816612+mlynam@users.noreply.github.com>
mlynam
left a comment
There was a problem hiding this comment.
Actions should have a common action export. The errors generated may or may not be from zod. We know we will have more than one action so we can generalize the access error handling so we have common functions to handle a zod error and other errors that may appear.
…dling Implements feedback from code review: - Created lib/actions.ts with withAuth wrapper for server actions - Added common error handling utilities (handleActionError, createActionError, createActionSuccess) - Updated getUserProfile to use new withAuth pattern - Fixed TypeScript 'any' types to use 'unknown' for proper type safety - Fixed ESLint configuration for monorepo packages - Replaced <a> with <Link> in home page for proper Next.js navigation The withAuth wrapper simplifies authentication in server actions by: - Automatically checking session and returning error if unauthorized - Providing authenticated user object as first parameter - Reducing boilerplate code in every action Error handling utilities provide: - Consistent error format across all actions - Special handling for Zod validation errors vs general errors - Type-safe ActionResult type for all server actions Co-authored-by: mlynam <2816612+mlynam@users.noreply.github.com>
Created common action utilities in
All utilities follow the error handling pattern from the Netsurit Architect standards. (587bae0) |
Adds legacy:* commands to run the original React+Vite application during migration: - legacy:dev - Run Vite dev server - legacy:build - Build with Vite - legacy:lint - ESLint for old app - legacy:test/test:watch/test:ui/test:coverage - Vitest commands - legacy:smoke-test/smoke-test:prod - Smoke testing - legacy:preview - Preview Vite build - legacy:deploy - Deploy to gh-pages These allow continued use of the original app alongside the new NextJS monorepo during Phase 2 migration. Legacy commands can be removed once their functionality is fully migrated to the monorepo. Co-authored-by: mlynam <2816612+mlynam@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. |
…dards Refactored lib/actions.ts into individual files following Netsurit Architect "one export per file" pattern: Created lib/actions/ directory with: - ActionResult.ts - Type definition for action results - withAuth.ts - Authentication wrapper HOF - formatZodError.ts - Zod error formatter - createActionError.ts - Error response builder - createActionSuccess.ts - Success response builder - handleActionError.ts - Centralized error handler - index.ts - Barrel export for all utilities Benefits: - Follows Google TypeScript style guide - Each file has single responsibility - Export names match filenames - Clean imports via barrel export pattern - Easier to maintain and refactor individual utilities No breaking changes - imports from '@/lib/actions' continue to work via barrel export. Co-authored-by: mlynam <2816612+mlynam@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. |
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.