slack-logs 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/index.js +2 -2
- package/dist/index.ts +4 -4
- package/package.json +1 -1
- package/src/index.ts +4 -4
package/README.md
CHANGED
|
@@ -38,7 +38,16 @@ Here is a basic example of how to use the Slack Log package to send a message to
|
|
|
38
38
|
|
|
39
39
|
```
|
|
40
40
|
...
|
|
41
|
-
|
|
41
|
+
# Slack Webhook URL for sending logs and notifications.
|
|
42
|
+
# Replace with your actual webhook URL.
|
|
43
|
+
SLACK_WEBHOOK_URL="https://hooks.slack.com/services/******/******/********************
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Optional field, defaults to "true".
|
|
47
|
+
# Set to "false" to disable Slack logs globally without changing the code.
|
|
48
|
+
ENABLE_SLACK_LOGS=true
|
|
49
|
+
# Note: No need to define this variable unless you want to disable Slack logs.
|
|
50
|
+
# If variable is not defined, it defaults to "true".
|
|
42
51
|
...
|
|
43
52
|
```
|
|
44
53
|
|
package/dist/index.js
CHANGED
|
@@ -97,8 +97,8 @@ function isValidSlackWebhookUrl() {
|
|
|
97
97
|
return SLACK_WEBHOOK_URL.startsWith("https://");
|
|
98
98
|
}
|
|
99
99
|
async function axiosCall(payload) {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
100
|
+
const ENABLE_SLACK_LOGS = (process?.env?.ENABLE_SLACK_LOGS ?? "").toString() === "true";
|
|
101
|
+
if (ENABLE_SLACK_LOGS)
|
|
102
102
|
return false;
|
|
103
103
|
const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
|
|
104
104
|
return await axios_1.default
|
package/dist/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ export const slack: Slack = {
|
|
|
52
52
|
if (!isValidSlackWebhookUrl()) {
|
|
53
53
|
// SLACK_WEBHOOK_URL is valid
|
|
54
54
|
console.error(
|
|
55
|
-
"🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
|
|
55
|
+
"🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
|
|
56
56
|
);
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
@@ -120,10 +120,10 @@ function isValidSlackWebhookUrl(): boolean {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
async function axiosCall(payload: any) {
|
|
123
|
-
const
|
|
124
|
-
process?.env?.
|
|
123
|
+
const ENABLE_SLACK_LOGS: boolean =
|
|
124
|
+
(process?.env?.ENABLE_SLACK_LOGS ?? "").toString() === "true";
|
|
125
125
|
|
|
126
|
-
if (
|
|
126
|
+
if (ENABLE_SLACK_LOGS) return false;
|
|
127
127
|
|
|
128
128
|
const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
|
|
129
129
|
return await axios
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ export const slack: Slack = {
|
|
|
52
52
|
if (!isValidSlackWebhookUrl()) {
|
|
53
53
|
// SLACK_WEBHOOK_URL is valid
|
|
54
54
|
console.error(
|
|
55
|
-
"🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
|
|
55
|
+
"🚨 Invalid Slack webhook URL. Kindly check 'SLACK_WEBHOOK_URL' in your .env file! 🚨"
|
|
56
56
|
);
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
@@ -120,10 +120,10 @@ function isValidSlackWebhookUrl(): boolean {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
async function axiosCall(payload: any) {
|
|
123
|
-
const
|
|
124
|
-
process?.env?.
|
|
123
|
+
const ENABLE_SLACK_LOGS: boolean =
|
|
124
|
+
(process?.env?.ENABLE_SLACK_LOGS ?? "").toString() === "true";
|
|
125
125
|
|
|
126
|
-
if (
|
|
126
|
+
if (ENABLE_SLACK_LOGS) return false;
|
|
127
127
|
|
|
128
128
|
const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
|
|
129
129
|
return await axios
|