305 lines
11 KiB
Markdown
305 lines
11 KiB
Markdown
# CyberHybridHub TODO
|
|
|
|
## High Priority 🔴
|
|
|
|
### Error Handling Improvements
|
|
|
|
- [ ] **Replace console.log statements with proper logging**
|
|
- routes/api/payments/set_auto_pay.ts (line 80)
|
|
- routes/api/payments/cancel_auto_pay.ts (line 65)
|
|
- routes/tenant/settings/index.tsx (line 50)
|
|
- routes/tenant/payment-methods/index.tsx (lines 33, 43)
|
|
- Use utils/logging.ts functions (writeAudioLog, writeImageLog, logBlobFetch) or create new logging utilities
|
|
|
|
- [ ] **Standardize error handling across API routes**
|
|
- Many catch blocks use generic error handling without proper logging
|
|
- Some routes return `JSON.stringify(e)` which may not be safe
|
|
- Create proper error classes and error types
|
|
- Implement consistent error response format
|
|
|
|
- [ ] **Add proper error logging infrastructure**
|
|
- Extend utils/logging.ts with general error logging functions
|
|
- Add request ID tracking for better debugging
|
|
- Implement structured logging with log levels (error, warn, info, debug)
|
|
|
|
### TypeScript Type Safety
|
|
|
|
- [ ] **Replace `any` types with proper TypeScript types**
|
|
- **Utils & Types:**
|
|
- utils/request_handler.ts (line 7)
|
|
- types/graph/ServicePrincipal.ts (lines 34, 43, 45, 46)
|
|
- utils/TextToQuizTranslations.ts (line 33)
|
|
- db/interfaces.ts (lines 60, 204, 251)
|
|
- **Islands:**
|
|
- islands/AsyncImageGenerater.tsx (line 35)
|
|
- islands/ClearCheckedButton.tsx (lines 4-5)
|
|
- islands/SyncButton.tsx (line 7)
|
|
- islands/ArrangeQuiz.tsx (lines 145, 190, 235, 254)
|
|
- islands/Card.tsx (line 332)
|
|
- islands/StudyButton.tsx (line 7)
|
|
- islands/AdminPage.tsx (line 187)
|
|
- islands/dialogs/AddRentalDialog.tsx (line 4)
|
|
- islands/dialogs/AddLeaseDialog.tsx (line 4)
|
|
- islands/TranslationList.tsx (line 273)
|
|
- islands/UserDashboard.tsx (lines 1136, 1167, 1196, 1235, 1264, 1349)
|
|
- **Routes:**
|
|
- routes/auth/validate.ts (line 96)
|
|
- routes/landlord/onboarding/profile.tsx (line 111)
|
|
- routes/api/update/payment_method.ts (line 51)
|
|
- routes/landlord/maintenance/index.tsx (line 68)
|
|
- **Services & Modules:**
|
|
- services/stateMiddleware.ts (line 104)
|
|
- modules/KvCacheStore.ts (lines 635, 636, 839, 850, 858)
|
|
- **Tests:**
|
|
- tests/e2e/helpers.ts (line 12)
|
|
|
|
- [ ] **Add proper type definitions for event handlers**
|
|
- Create shared types for form event handlers
|
|
- Define proper types for onChange, onSubmit, etc.
|
|
- Use Preact's specific event types
|
|
|
|
## Medium Priority 🟡
|
|
|
|
### API Endpoints & Services
|
|
|
|
- [ ] **Create reminder API endpoints**
|
|
- POST /api/create/reminder - Create new reminder
|
|
- GET /api/retrieve/reminders - Get reminders for user
|
|
- PUT /api/update/reminder - Update reminder
|
|
- DELETE /api/delete/reminder - Delete reminder
|
|
- PUT /api/update/reminder/complete - Mark reminder as completed
|
|
- Service exists: services/reminderService.ts
|
|
|
|
- [ ] **Create financial data API endpoints**
|
|
- GET /api/retrieve/obligations - Get user obligations
|
|
- GET /api/retrieve/incomes - Get user incomes
|
|
- Service exists: services/financhalServices.ts
|
|
|
|
- [ ] **Verify all API endpoints have proper error handling**
|
|
- Review all routes/api/create/* files
|
|
- Review all routes/api/update/* files
|
|
- Review all routes/api/delete/* files
|
|
- Review all routes/api/retrieve/* files
|
|
- Ensure consistent error response format
|
|
|
|
### Code Quality & Testing
|
|
|
|
- [ ] **Run and fix TypeScript compilation errors**
|
|
- Run `deno check` to identify issues
|
|
- Fix all type mismatches
|
|
- Ensure all files pass type checking
|
|
|
|
- [ ] **Validate all changed files**
|
|
- Run `deno fmt` for formatting
|
|
- Run `deno lint` for code quality
|
|
- Run `deno check` for type checking
|
|
|
|
- [ ] **Add unit tests for services**
|
|
- services/paymentService.ts
|
|
- services/leaseService.ts
|
|
- services/reminderService.ts
|
|
- services/financhalServices.ts
|
|
- services/tenantInviteService.ts
|
|
|
|
- [ ] **Add integration tests for API endpoints**
|
|
- Test all create endpoints
|
|
- Test all update endpoints
|
|
- Test all delete endpoints
|
|
- Test all retrieve endpoints
|
|
|
|
### Database & Schema
|
|
|
|
- [ ] **Verify database schema supports all features**
|
|
- Check lease table supports required states (new, signed, active)
|
|
- Verify tenant_id column is nullable in lease table
|
|
- Confirm all required fields exist for reminders
|
|
- Validate financial tables (obligations, incomes) schema
|
|
|
|
- [ ] **Add database migration documentation**
|
|
- Document existing migrations in drizzle/ directory
|
|
- Add migration rollback procedures
|
|
- Document schema evolution
|
|
|
|
## Low Priority 🟢
|
|
|
|
### Documentation
|
|
|
|
- [ ] **Update README.md with setup instructions**
|
|
- Add environment variable configuration guide
|
|
- Document all required environment variables
|
|
- Add troubleshooting section
|
|
|
|
- [ ] **Add API documentation**
|
|
- Document all API endpoints
|
|
- Include request/response examples
|
|
- Add authentication requirements
|
|
|
|
- [ ] **Create developer onboarding guide**
|
|
- Project structure overview
|
|
- Development workflow
|
|
- Testing guidelines
|
|
- Code style guidelines
|
|
|
|
### Performance & Optimization
|
|
|
|
- [ ] **Optimize database queries**
|
|
- Review all service functions for N+1 queries
|
|
- Add proper indexes where needed
|
|
- Implement query result caching
|
|
|
|
- [ ] **Add request/response caching**
|
|
- Cache frequently accessed data
|
|
- Implement cache invalidation strategy
|
|
- Use Deno KV for caching (already configured)
|
|
|
|
- [ ] **Optimize bundle size**
|
|
- Analyze production bundle
|
|
- Remove unused dependencies
|
|
- Implement code splitting
|
|
|
|
### Security
|
|
|
|
- [ ] **Add input validation middleware**
|
|
- Validate all incoming request data
|
|
- Sanitize user inputs
|
|
- Prevent injection attacks
|
|
|
|
- [ ] **Add rate limiting**
|
|
- Implement rate limiting for API endpoints
|
|
- Add rate limiting for authentication endpoints
|
|
- Configure rate limits per endpoint type
|
|
|
|
- [ ] **Add security headers**
|
|
- Content Security Policy (CSP)
|
|
- X-Frame-Options
|
|
- X-Content-Type-Options
|
|
- Strict-Transport-Security (HSTS)
|
|
|
|
## Completed Items ✅
|
|
|
|
### Lease Creation Feature Implementation
|
|
|
|
- [x] **Implement `getTransactionByStripeId(stripeId: string)`** in `services/paymentService.ts`
|
|
- ✅ EXISTS at line 391
|
|
- Used by routes/api/receipt/[id].ts and routes/api/payments/webhook.ts
|
|
|
|
- [x] **POST `/api/leases`** - Create new lease endpoint
|
|
- ✅ EXISTS at routes/api/create/lease.ts
|
|
- Request body validation (rent, deposit, propertyId, dates)
|
|
- Database insertion with `new` state
|
|
- Returns created lease object
|
|
|
|
- [x] **PUT `/api/leases/:id/invite`** - Send tenant invitation
|
|
- ✅ EXISTS at routes/api/update/lease_invite.ts
|
|
- Generates invitation token
|
|
- Creates tenant invite
|
|
- Updates lease status
|
|
|
|
- [x] **PUT `/api/leases/:id/accept`** - Tenant accepts invitation
|
|
- ✅ EXISTS at routes/api/update/lease_accept.ts
|
|
- Validates invitation token
|
|
- Updates lease tenant field and status to `signed`
|
|
|
|
- [x] **Create lease creation form component**
|
|
- ✅ AddLeaseDialog.tsx exists
|
|
- ✅ PopAddLeaseDialog.tsx exists
|
|
- Rent amount input field
|
|
- Security deposit amount input field
|
|
- Property selection dropdown
|
|
- Lease term start/end date pickers
|
|
- Form validation and error handling
|
|
|
|
- [x] **Add "Create New Lease" button on landlord dashboard**
|
|
- ✅ Available at /leased-home route
|
|
- ✅ LeasedHome island component exists
|
|
|
|
- [x] **Tenant invitation interface**
|
|
- ✅ LandlordInviteTenant.tsx exists
|
|
- Email input and invitation sending UI
|
|
|
|
## Next Steps
|
|
2. Replace console.log statements with proper logging
|
|
3. Standardize error handling across all API routes
|
|
4. Replace TypeScript any types with proper types
|
|
5. Create missing API endpoints for reminders and financial data
|
|
6. Add comprehensive error logging infrastructure
|
|
7. Run deno check, fmt, and lint to fix code quality issues
|
|
8. Add unit and integration tests for services and API endpoints
|
|
9. Update documentation with setup and API guides
|
|
10. Implement performance optimizations and security enhancements
|
|
|
|
#### Frontend Components
|
|
- [ ] **Create lease creation form component** (`components/LeaseForm.tsx`)
|
|
- Rent amount input field
|
|
- Security deposit amount input field
|
|
- Property selection dropdown
|
|
- Lease term start/end date pickers
|
|
- Form validation and error handling
|
|
- [ ] **Add "Create New Lease" button next to "Add Property" button** on landlord dashboard (`/dashboard/landlord` route)
|
|
- [ ] **Create lease creation modal/page** (`routes/landlord/create-lease.tsx`)
|
|
- [ ] **Tenant invitation interface** - Email input and invitation sending UI
|
|
|
|
#### Backend API Endpoints
|
|
- [ ] **POST `/api/leases`** - Create new lease endpoint
|
|
- Request body validation (rent, deposit, propertyId, dates)
|
|
- Database insertion with `new` state
|
|
- Return created lease object
|
|
- [ ] **PUT `/api/leases/:id/invite`** - Send tenant invitation
|
|
- Generate invitation token
|
|
- Send email to tenant
|
|
- Update lease status
|
|
- [ ] **PUT `/api/leases/:id/accept`** - Tenant accepts invitation
|
|
- Validate invitation token
|
|
- Update lease tenant field and status to `signed`
|
|
|
|
## Medium Priority 🟡
|
|
|
|
### Payment Service Fixes
|
|
- [ ] **Implement `getTransactionByStripeId(stripeId: string)`** in `services/paymentService.ts`
|
|
- Query database by stripe transaction ID
|
|
- Return transaction object or null
|
|
- [ ] **Fix TypeScript import errors** in receipt API routes
|
|
- Check all `routes/api/receipts/` files
|
|
- Fix relative import paths
|
|
- [ ] **Add proper TypeScript types** for Fresh route handlers
|
|
- Define request/response types for API endpoints
|
|
- Update handler function signatures
|
|
|
|
### Code Quality & Testing
|
|
- [ ] **Fix TypeScript compilation errors**
|
|
- Run `deno check` to identify issues
|
|
- Fix all type mismatches
|
|
- [ ] **Validate all changed files**
|
|
- Run `deno fmt` for formatting
|
|
- Run `deno lint` for code quality
|
|
- Run `deno check` for type checking
|
|
- [ ] **Test lease creation workflow end-to-end**
|
|
- Manual testing in development environment
|
|
- Verify database state changes
|
|
- Test tenant invitation flow
|
|
|
|
## Low Priority 🟢
|
|
|
|
### Testing Infrastructure
|
|
- [ ] **Unit tests for lease creation** (`tests/unit/lease.test.ts`)
|
|
- [ ] **Integration tests for tenant invitation flow** (`tests/integration/invitation.test.ts`)
|
|
- [ ] **E2E tests for complete lease lifecycle** (`tests/e2e/lease-lifecycle.spec.ts`)
|
|
- [ ] **Payment service integration tests** (`tests/integration/payment.test.ts`)
|
|
|
|
## Database Schema Verification Needed
|
|
- [ ] **Verify lease table supports required states**
|
|
- Check `state` column accepts `new` and `signed`
|
|
- Verify `tenant_id` column is nullable
|
|
- Confirm all required fields exist
|
|
|
|
## Current Blockers
|
|
- ❌ **TypeScript compilation errors** preventing development
|
|
- ❌ **Missing payment service functions** breaking receipt functionality
|
|
|
|
## Next Steps
|
|
1. Fix immediate TypeScript and payment service issues
|
|
2. Implement lease creation API endpoints
|
|
3. Create frontend components for lease management
|
|
4. Test complete workflow end-to-end
|
|
|