Skip to content

Commit

Permalink
[@dhealthdapps/backend] fix: linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nsonanh authored and evias committed Jan 17, 2023
1 parent b265700 commit aa90d5a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
6 changes: 1 addition & 5 deletions runtime/backend/src/common/services/QueryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,7 @@ export class QueryService<
const { queryCursor, searchQuery } = this.getQueryConfig(query);

// execute Mongo query
const data = await model
.find(
searchQuery as FilterQuery<TDocument>
)
.exec();
const data = await model.find(searchQuery as FilterQuery<TDocument>).exec();

// build pagination details for PaginatedResultDTO
const pagination = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
*/
export abstract class BasicWebHookEventRequest {
public abstract get remoteIdentifier(): string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
*/
export abstract class BasicWebHookSubscriptionRequest {
public abstract get subscriptionValidationObject(): object;
}
}
5 changes: 2 additions & 3 deletions runtime/backend/src/oauth/drivers/EventHandlerStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// internal dependencies
import { ActivityDocument } from "../../users/models/ActivitySchema";
import { BasicWebHookEventRequest } from "./BasicWebHookEventRequest";
Expand All @@ -8,5 +7,5 @@ export interface EventHandlerStrategy {
providerName: string,
userAddress: string,
data: BasicWebHookEventRequest,
): Promise<ActivityDocument>
}
): Promise<ActivityDocument>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export class EventHandlerStrategyFactory {
) {}

public create(providerName: string): EventHandlerStrategy {
switch(providerName) {
case "strava": return this.stravaEventHandlerStrategy;
switch (providerName) {
case "strava":
return this.stravaEventHandlerStrategy;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { EventEmitter2 } from "@nestjs/event-emitter";
import moment from "moment";

// internal dependencies
import { Activity, ActivityDocument, ActivityModel, ActivityQuery } from "../../../users/models/ActivitySchema";
import {
Activity,
ActivityDocument,
ActivityModel,
ActivityQuery,
} from "../../../users/models/ActivitySchema";
import { EventHandlerStrategy } from "../EventHandlerStrategy";
import { StravaWebHookEventRequest } from "./StravaWebHookEventRequest";
import { ActivitiesService } from "../../../users/services/ActivitiesService";
Expand All @@ -21,7 +26,10 @@ export class StravaEventHandlerStrategy implements EventHandlerStrategy {
@InjectModel(Activity.name)
private readonly model: ActivityModel,
private readonly activitiesService: ActivitiesService,
private readonly queryService: QueryService<ActivityDocument, ActivityModel>,
private readonly queryService: QueryService<
ActivityDocument,
ActivityModel
>,
private readonly eventEmitter: EventEmitter2,
) {}

Expand All @@ -46,10 +54,11 @@ export class StravaEventHandlerStrategy implements EventHandlerStrategy {
async eventHandler(
providerName: string,
userAddress: string,
data: BasicWebHookEventRequest
data: BasicWebHookEventRequest,
): Promise<ActivityDocument> {
// destructure obligatory fields for validation
const { object_type, object_id, aspect_type, owner_id, event_time } = data as StravaWebHookEventRequest;
const { object_type, object_id, aspect_type, owner_id, event_time } =
data as StravaWebHookEventRequest;

// make sure we have all obligatory fields
if (!object_type || !object_id || !aspect_type || !owner_id) {
Expand Down Expand Up @@ -132,4 +141,4 @@ export class StravaEventHandlerStrategy implements EventHandlerStrategy {
);
}
}
}
}
5 changes: 1 addition & 4 deletions runtime/backend/src/oauth/routes/WebHooksController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ export class WebHooksController {
description:
"This endpoint is called by third-party data providers to initially create webhook subscriptions for remote accounts.",
})
@ApiExtraModels(
BasicWebHookEventRequest,
BasicWebHookSubscriptionRequest,
)
@ApiExtraModels(BasicWebHookEventRequest, BasicWebHookSubscriptionRequest)
@ApiOkResponse(HTTPResponses.WebhookGetResponseSchema)
protected async subscribe(
@NestResponse() response: Response,
Expand Down

0 comments on commit aa90d5a

Please sign in to comment.