Now sending webhooks to both the webserver and meili
This commit is contained in:
parent
dfbf3c9840
commit
e2cd4a9388
|
@ -13,8 +13,11 @@ SEEDING_ADMIN_USERNAME=admin_name
|
|||
SEEDING_ADMIN_EMAIL=email@domain.com
|
||||
SEEDING_ADMIN_PASSWORD=somepassword
|
||||
|
||||
WEB_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
||||
WEB_HOOK_URI=https://accords-library.com/some/path
|
||||
WEB_SERVER_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
||||
WEB_SERVER_HOOK_URL=https://accords-library.com/some/path
|
||||
|
||||
MEILISEARCH_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
||||
MEILISEARCH_HOOK_URL=https://meili.domain.com
|
||||
|
||||
SFTP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nxxxxxxxxxx..."
|
||||
SFTP_USERNAME=someuser
|
||||
|
|
|
@ -68,14 +68,21 @@ export const afterDeleteWebhook: AfterDeleteHook = async ({ collection, doc }) =
|
|||
};
|
||||
|
||||
const sendWebhookMessage = async (message: AfterOperationWebHookMessage) => {
|
||||
await fetch(`${process.env.WEB_HOOK_URI}/collection-operation`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WEB_HOOK_TOKEN}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(message),
|
||||
method: "POST",
|
||||
}).catch((e) => {
|
||||
try {
|
||||
await Promise.all(
|
||||
[process.env.WEB_SERVER_HOOK_URL, process.env.MEILISEARCH_HOOK_URL].flatMap((url) => {
|
||||
if (!url) return;
|
||||
return fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.WEB_SERVER_HOOK_TOKEN}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(message),
|
||||
method: "POST",
|
||||
});
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn("Error while sending webhook", e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 47c990080173a2330f0c7a9837dac34dba4e0811
|
||||
Subproject commit 824f7085f9e0787f97ef9afd11cb5320a2cd6208
|
|
@ -6,7 +6,7 @@ export const shortenEllipsis = (text: string, length: number): string =>
|
|||
text.length - 3 > length ? `${text.substring(0, length)}...` : text;
|
||||
|
||||
export const formatLanguageCode = (code: string): string =>
|
||||
tags(code).valid() ? tags(code).language()?.descriptions()[0] ?? code : code;
|
||||
tags(code).valid() ? (tags(code).language()?.descriptions()[0] ?? code) : code;
|
||||
|
||||
export const capitalize = (string: string): string => {
|
||||
const [firstLetter, ...otherLetters] = string;
|
||||
|
|
Loading…
Reference in New Issue