Repository navigation
feat: add POST /coordinators endpoint with Cognito user creation - #9
pujitakalinadhabhotla wants to merge 1 commit into
Conversation
dburkhart07
left a comment
There was a problem hiding this comment.
can we comment out the lines 90-95 in the cognito guard, so that we can enable auth (and therefore have access to cognito), the guard runs, but skips token verification?
| @IsString() | ||
| lastName!: string; | ||
|
|
||
| @IsString() |
There was a problem hiding this comment.
both of these need @IsPhoneNumber('US')
|
|
||
| // Accepts every FosterCoordinator field except `active` (defaults to true) and | ||
| // `assignedVolunteers` (defaults to []), which are not client-settable on create. | ||
| export class CreateCoordinatorDto { |
There was a problem hiding this comment.
For all the strings can we add a MaxLength using the coordinator entity for the exact number of characters each should be? Phone number doesn't need a max length
| let controller: CoordinatorsController; | ||
| let service: jest.Mocked<CoordinatorsService>; | ||
|
|
||
| const dto: CreateCoordinatorDto = { |
There was a problem hiding this comment.
can we cast this with as CreateCoordinatorDto so that, even if it's missing a field, it won't throw an error?
|
|
||
| it('should be defined', () => { | ||
| expect(controller).toBeDefined(); | ||
| it('delegates creation to the service and returns the created coordinator', async () => { |
There was a problem hiding this comment.
can we add tests for error propagation for each specific error that may be thrown? so bad request and conflict?
| private cognitoService: CognitoService, | ||
| ) {} | ||
|
|
||
| /** |
There was a problem hiding this comment.
add a parameter for the body
| const coordinator = this.repo.create({ | ||
| ...dto, | ||
| active: true, | ||
| assignedVolunteers: [], |
There was a problem hiding this comment.
can we initialize this list to be all foster volunteers that have the same homebase as the coordinator?
| }) | ||
| secondaryPhone!: string | null; | ||
|
|
||
| @Column({ type: 'varchar', length: 255 }) |
There was a problem hiding this comment.
sorry, this is an additional request that came to me as i was reviewing this pr, but can we make it so that the email fields for coordinators, volunteers, and admin are all unique? this will require an entity change in each, and a migration to write on top of it. we can honestly just add this into the migration you've already written in this pr.
| export class CoordinatorsController { | ||
| constructor(private coordinatorsService: CoordinatorsService) {} | ||
|
|
||
| @Post() |
There was a problem hiding this comment.
Lets add a @public() decorator to this since everyone is going to need to have access to it when we eventually enable auth fully
ℹ️ Issue
Closes MSPCA-19
📝 Description
Adds a
POST /coordinatorsendpoint to create Foster Coordinators (MSPCA staff accounts, separate from volunteers).@mspca.org.mspca-user-pool) and adds them to theFosterCoordinatorgroup.subon a newcognito_subcolumn (migration included, defaults to'').Also handles duplicate emails and missing/invalid fields, and includes service + controller tests with Cognito calls mocked.
✔️ Verification
cognito_subwas added tofoster_coordinators.yarn test— all tests passing.POST /coordinatorsand confirmed valid coordinators are created with acognito_sub, invalid emails are rejected, and duplicates are rejected without creating a row.(Backend-only change, no screenshots.)
🏕️ (Optional) Future Work / Notes