Skip to content

Commit

Permalink
remove unneeded dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: david <david@umaproject.org>
  • Loading branch information
daywiss committed Nov 21, 2024
1 parent 5c308e0 commit 61e2ef2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 56 deletions.
3 changes: 1 addition & 2 deletions packages/webhooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"express": "^4.19.2",
"express-bearer-token": "^3.0.0",
"redis": "^4.7.0",
"superstruct": "2.0.3-1",
"typeorm": "^0.3.20"
"superstruct": "2.0.3-1"
},
"exports": {
".": "./dist/index.js"
Expand Down
3 changes: 1 addition & 2 deletions packages/webhooks/src/database/webhookClientRepository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DataSource } from "typeorm";
import { entities } from "@repo/indexer-database";
import { entities, DataSource } from "@repo/indexer-database";

// This class is intended to store integration clients allowed to use the webhook service.
export class WebhookClientRepository {
Expand Down
14 changes: 7 additions & 7 deletions packages/webhooks/src/database/webhookRequestRepository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { DataSource } from "typeorm";
import { WebhookRequest } from "../types";
import { entities } from "@repo/indexer-database";
import { entities, DataSource } from "@repo/indexer-database";

export class WebhookRequestRepository {
private repository;
Expand All @@ -9,7 +7,7 @@ export class WebhookRequestRepository {
this.repository = this.dataSource.getRepository(entities.WebhookRequest);
}

public async register(webhook: WebhookRequest): Promise<void> {
public async register(webhook: entities.WebhookRequest): Promise<void> {
const existingWebhook = await this.repository.findOne({
where: { id: webhook.id },
});
Expand All @@ -31,17 +29,19 @@ export class WebhookRequestRepository {

public async getWebhook(
webhookId: string,
): Promise<WebhookRequest | undefined> {
): Promise<entities.WebhookRequest | undefined> {
return (
(await this.repository.findOne({ where: { id: webhookId } })) ?? undefined
);
}

public async listWebhooks(): Promise<WebhookRequest[]> {
public async listWebhooks(): Promise<entities.WebhookRequest[]> {
return this.repository.find();
}

public async filterWebhooks(filter: string): Promise<WebhookRequest[]> {
public async filterWebhooks(
filter: string,
): Promise<entities.WebhookRequest[]> {
return this.repository.find({ where: { filter } });
}

Expand Down
8 changes: 4 additions & 4 deletions packages/webhooks/src/eventProcessors/depositStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class DepositStatusProcessor implements IEventProcessor {
private postgres: DataSource;
// Type shoudl be uniqe across all event processors, this is to avoid colliding with multiple
// processors writing to the same tables
public type = "DepositStatus";
static type = "DepositStatus";

constructor(deps: Dependencies) {
this.webhookRequests = new WebhookRequestRepository(deps.postgres);
Expand All @@ -40,7 +40,7 @@ export class DepositStatusProcessor implements IEventProcessor {
}
private async _write(event: DepositStatusEvent): Promise<void> {
const filter = customId(
this.type,
DepositStatusProcessor.type,
event.originChainId,
event.depositTxHash,
);
Expand All @@ -65,13 +65,13 @@ export class DepositStatusProcessor implements IEventProcessor {
params: DepositStatusFilter,
): Promise<string> {
const id = customId(
this.type,
DepositStatusProcessor.type,
url,
params.originChainId,
params.depositTxHash,
);
const filter = customId(
this.type,
DepositStatusProcessor.type,
params.originChainId,
params.depositTxHash,
);
Expand Down
2 changes: 0 additions & 2 deletions packages/webhooks/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { DataSource } from "@repo/indexer-database";
import { Logger } from "winston";
import { WebhookNotifier } from "./notifier";
import { DepositStatusProcessor } from "./eventProcessors";
import { WebhookRequestRepository } from "./database/webhookRequestRepository";
import { WebhookRouter } from "./router";
import { entities } from "@repo/indexer-database";

export enum WebhookTypes {
DepositStatus = "DepositStatus",
Expand Down
6 changes: 0 additions & 6 deletions packages/webhooks/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as ss from "superstruct";

export interface WebhookRequest {
id: string;
url: string;
filter: string;
}

export interface IEventProcessor {
write(event: JSONValue): void;
register(url: string, params: JSONValue): Promise<string>;
Expand Down
57 changes: 24 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61e2ef2

Please sign in to comment.