@@ -40,6 +40,7 @@ interface HttpEvent {
4040 to ?: string ;
4141 stackBy ?: string ;
4242 includeRawEvents ?: string ;
43+ learnerId ?: string ;
4344 userId ?: string ;
4445 } ;
4546 body ?: string | null ;
@@ -114,8 +115,11 @@ export async function handler(event: HttpEvent): Promise<{
114115 const method = event . requestContext ?. http ?. method ;
115116 const path = event . rawPath ?? event . requestContext ?. http ?. path ?? "" ;
116117
118+ if ( method === "GET" && path === "/learners/by-id/context" ) {
119+ return await handleGetLearnerContext ( event , true ) ;
120+ }
117121 if ( method === "GET" && path . includes ( "/learners/" ) && path . endsWith ( "/context" ) ) {
118- return await handleGetLearnerContext ( event ) ;
122+ return await handleGetLearnerContext ( event , false ) ;
119123 }
120124 if ( method === "GET" && path === "/users" ) {
121125 return await handleListUsers ( ) ;
@@ -157,13 +161,13 @@ export async function handler(event: HttpEvent): Promise<{
157161 }
158162}
159163
160- async function handleGetLearnerContext ( event : HttpEvent ) {
161- const learnerId = event . pathParameters ?. learnerId ;
164+ async function handleGetLearnerContext ( event : HttpEvent , fromQuery : boolean ) {
165+ const learnerId = fromQuery ? event . queryStringParameters ?. learnerId : event . pathParameters ?. learnerId ;
162166 if ( ! learnerId ) {
163167 return json ( 400 , {
164168 status : "rejected" ,
165169 reason : "missing_learner_id" ,
166- details : [ "learnerId path parameter is required." ]
170+ details : [ "learnerId is required." ]
167171 } ) ;
168172 }
169173
0 commit comments