Skip to content

Commit

Permalink
WIP: pass access token to backend for list services [deploy]
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-Andrews99 committed Sep 16, 2024
1 parent 31b35d4 commit ab1410c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions express/src/services/lambda-facade/LambdaFacade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export default class LambdaFacade implements LambdaFacadeInterface {
}
}

listServices(userId: string): Promise<AxiosResponse> {
return this.get(`/get-services/${userId}`);
listServices(userId: string, accessToken: string): Promise<AxiosResponse> {
return this.get(`/get-services/${userId}`, accessToken);
}

listClients(serviceId: string, accessToken: string): Promise<AxiosResponse<QueryCommandOutput>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default interface LambdaFacadeInterface {

generateClient(service: Service, authenticationResult: AuthenticationResultType): Promise<AxiosResponse>;

listServices(userId: string): Promise<AxiosResponse>;
listServices(userId: string, accessToken: string): Promise<AxiosResponse>;

// TODO The QueryCommandOutput type should be replaced by a class shared between the frontend and the API (contract)
listClients(serviceId: string, accessToken: string): Promise<AxiosResponse<QueryCommandOutput>>;
Expand Down
6 changes: 4 additions & 2 deletions express/src/services/self-service-services-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export default class SelfServiceServicesService {
async listServices(userId: string, accessToken: string): Promise<Service[]> {
console.info("In self-service-services-service:listServices()");
await this.validateToken(accessToken, "listServices");
return dynamoServicesToDomainServices((await this.lambda.listServices(userId)).data.Items);
return dynamoServicesToDomainServices((await this.lambda.listServices(userId, accessToken)).data.Items);
}

async updateUser(userId: string, updates: UserUpdates, accessToken: string): Promise<void> {
Expand Down Expand Up @@ -363,7 +363,9 @@ export default class SelfServiceServicesService {
async recreateDynamoDBAccountLinks(authenticationResult: AuthenticationResultType, oldUserID: string) {
console.info("In self-service-services-service:createNewDynamoDBAccountLinks()");

const serviceListToReplicate = dynamoServicesToDomainServices((await this.lambda.listServices(oldUserID)).data.Items);
const serviceListToReplicate = dynamoServicesToDomainServices(
(await this.lambda.listServices(oldUserID, nonNull(authenticationResult.AccessToken))).data.Items
);

for (const serviceItem of serviceListToReplicate) {
const serviceID: string = serviceItem.id;
Expand Down

0 comments on commit ab1410c

Please sign in to comment.