Skip to content

Refactor to monorepo architecture with NextJS App Router and TypeScript (Phase 1)#1

Merged
mlynam merged 8 commits into
mainfrom
copilot/refactor-codebase-to-monorepo
Feb 4, 2026
Merged

Refactor to monorepo architecture with NextJS App Router and TypeScript (Phase 1)#1
mlynam merged 8 commits into
mainfrom
copilot/refactor-codebase-to-monorepo

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 28, 2026

  • Create monorepo infrastructure with Turborepo + pnpm
  • Migrate to TypeScript strict mode
  • Set up NextAuth v5 with Azure AD
  • Create database layer with repository pattern
  • Implement first server action (getUserProfile)
  • Add common action utilities (withAuth, error handling)
  • Refactor actions to follow one-export-per-file pattern
  • Add legacy npm scripts for old app
  • Migrate remaining 43 Azure Functions to server actions
  • Migrate 8 React pages to App Router pages
  • Migrate shared utilities
  • Set up testing infrastructure

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 28, 2026 17:03
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>
Copilot AI changed the title [WIP] Refactor codebase to match Netsurit Architect style guidelines Refactor to monorepo architecture with NextJS App Router and TypeScript (Phase 1) Jan 28, 2026
Copilot AI requested a review from mlynam January 28, 2026 17:14
Copy link
Copy Markdown
Member

@mlynam mlynam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/web/services/users/getUserProfile.ts
…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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 30, 2026

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 ...

Created common action utilities in apps/web/lib/actions.ts:

  • withAuth - Auth wrapper for server actions
  • handleActionError - Handles Zod and general errors with consistent formatting
  • createActionError / createActionSuccess - Standard response builders
  • ActionResult<T> - Type-safe result type for all actions
  • formatZodError - Zod-specific error formatter

All utilities follow the error handling pattern from the Netsurit Architect standards. (587bae0)

Copilot AI requested a review from mlynam January 30, 2026 17:23
Comment thread package.json
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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 1, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Copilot AI requested a review from mlynam February 1, 2026 05:40
Comment thread apps/web/lib/actions.ts Outdated
…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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 4, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Copilot AI requested a review from mlynam February 4, 2026 04:17
@mlynam mlynam marked this pull request as ready for review February 4, 2026 04:46
@mlynam mlynam merged commit 4ef8d7f into main Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants