0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-10 21:58:23 -05:00

feat(core): init hooks schemas

This commit is contained in:
Gao Sun 2022-11-11 20:33:09 +08:00
parent aeb4fbc14a
commit 54c03f1a90
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
2 changed files with 30 additions and 0 deletions

View file

@ -200,3 +200,24 @@ export type Translation = {
export const translationGuard: z.ZodType<Translation> = z.lazy(() =>
z.record(z.string().or(translationGuard))
);
/**
* Hooks
*/
export type HookConfig = {
/** We don't need `type` since v1 only has web hook */
// type: 'web';
/** Method fixed to `POST` */
url: string;
/** Additional headers that attach to the request */
headers: Record<string, string>;
/** Only retry when status code >= 500 */
retries: number; //
};
export const hookConfigGuard: z.ZodType<HookConfig> = z.object({
url: z.string(),
headers: z.record(z.string()),
retries: z.number(),
});

View file

@ -0,0 +1,9 @@
create table hooks (
id varchar(128) not null,
event varchar(128) not null,
config jsonb /* @use HookConfig */ not null,
created_at timestamptz not null default(now()),
primary key (id)
);
create index hooks__event on hooks (event);