-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(webhooks): add postgres persistence to clients and requests (feature branch) #108
Changes from all commits
a06f222
7f636dc
d7b02f6
180a47e
969a6a9
22ddb90
b9cdea8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Entity, Column, PrimaryGeneratedColumn, Unique } from "typeorm"; | ||
|
||
@Entity() | ||
@Unique("UK_webhook_client_api_key", ["apiKey"]) | ||
export class WebhookClient { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this complicates things, but i can make it optional. right now we allow no client if configured that way |
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@Column() | ||
apiKey: string; | ||
|
||
@Column("jsonb") | ||
domains: string[]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
Entity, | ||
PrimaryColumn, | ||
Column, | ||
Unique, | ||
CreateDateColumn, | ||
Index, | ||
} from "typeorm"; | ||
|
||
@Entity() | ||
@Unique("UK_webhook_request_clientId_filter", ["clientId", "filter"]) | ||
@Index("IX_webhook_request_filter", ["filter"]) | ||
export class WebhookRequest { | ||
@PrimaryColumn() | ||
id: string; | ||
|
||
@Column({ type: "integer" }) | ||
clientId: number; | ||
|
||
@Column() | ||
url: string; | ||
|
||
@Column() | ||
filter: string; | ||
|
||
@CreateDateColumn() | ||
createdAt: Date; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class WebhookClient1732297474910 implements MigrationInterface { | ||
name = "WebhookClient1732297474910"; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
CREATE TABLE "webhook_client" ( | ||
"id" SERIAL NOT NULL, | ||
"name" character varying NOT NULL, | ||
"apiKey" character varying NOT NULL, | ||
"domains" jsonb NOT NULL, | ||
CONSTRAINT "UK_webhook_client_api_key" UNIQUE ("apiKey"), | ||
CONSTRAINT "PK_f7330fb3bdb2e19534eae691d44" PRIMARY KEY ("id") | ||
)`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "webhook_client"`); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class WebhookRequest1732297948190 implements MigrationInterface { | ||
name = "WebhookRequest1732297948190"; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
CREATE TABLE "webhook_request" ( | ||
"id" character varying NOT NULL, | ||
"clientId" integer NOT NULL, | ||
"url" character varying NOT NULL, | ||
"filter" character varying NOT NULL, | ||
"createdAt" TIMESTAMP NOT NULL DEFAULT now(), | ||
CONSTRAINT "UK_webhook_request_clientId_filter" UNIQUE ("clientId", "filter"), | ||
CONSTRAINT "PK_67a7784045de2d1b7139b611b93" PRIMARY KEY ("id") | ||
)`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "webhook_request"`); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class WebhookRequest1732310112989 implements MigrationInterface { | ||
name = "WebhookRequest1732310112989"; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE INDEX "IX_webhook_request_filter" ON "webhook_request" ("filter") `, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "public"."IX_webhook_request_filter"`); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,13 @@ | |
"license": "ISC", | ||
"dependencies": { | ||
"@repo/indexer-database": "workspace:*", | ||
"bullmq": "^5.12.12", | ||
"express": "^4.19.2", | ||
"express-bearer-token": "^3.0.0", | ||
"ioredis": "^5.4.1", | ||
"redis": "^4.7.0", | ||
"superstruct": "2.0.3-1" | ||
"superstruct": "2.0.3-1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooc is this a beta version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, their last official release has some import/export errors that are fixed in this beta version. |
||
"uuid": "^11.0.3" | ||
}, | ||
"exports": { | ||
".": "./dist/index.js" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should enforce uniqueness of the
apiKey