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_EMAIL=email@domain.com
|
||||||
SEEDING_ADMIN_PASSWORD=somepassword
|
SEEDING_ADMIN_PASSWORD=somepassword
|
||||||
|
|
||||||
WEB_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
WEB_SERVER_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
||||||
WEB_HOOK_URI=https://accords-library.com/some/path
|
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_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nxxxxxxxxxx..."
|
||||||
SFTP_USERNAME=someuser
|
SFTP_USERNAME=someuser
|
||||||
|
|
|
@ -68,14 +68,21 @@ export const afterDeleteWebhook: AfterDeleteHook = async ({ collection, doc }) =
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendWebhookMessage = async (message: AfterOperationWebHookMessage) => {
|
const sendWebhookMessage = async (message: AfterOperationWebHookMessage) => {
|
||||||
await fetch(`${process.env.WEB_HOOK_URI}/collection-operation`, {
|
try {
|
||||||
headers: {
|
await Promise.all(
|
||||||
Authorization: `Bearer ${process.env.WEB_HOOK_TOKEN}`,
|
[process.env.WEB_SERVER_HOOK_URL, process.env.MEILISEARCH_HOOK_URL].flatMap((url) => {
|
||||||
"Content-Type": "application/json",
|
if (!url) return;
|
||||||
},
|
return fetch(url, {
|
||||||
body: JSON.stringify(message),
|
headers: {
|
||||||
method: "POST",
|
Authorization: `Bearer ${process.env.WEB_SERVER_HOOK_TOKEN}`,
|
||||||
}).catch((e) => {
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(message),
|
||||||
|
method: "POST",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
console.warn("Error while sending webhook", 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;
|
text.length - 3 > length ? `${text.substring(0, length)}...` : text;
|
||||||
|
|
||||||
export const formatLanguageCode = (code: string): string =>
|
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 => {
|
export const capitalize = (string: string): string => {
|
||||||
const [firstLetter, ...otherLetters] = string;
|
const [firstLetter, ...otherLetters] = string;
|
||||||
|
|
Loading…
Reference in New Issue