a cache for slack profile pictures and emojis

feat: add better logging

Changed files
+22
src
+1
README.md
···
```bash
SLACK_TOKEN=xoxb-123456789012-123456789012-123456789012-123456789012
SLACK_SIGNING_SECRET=12345678901234567890123456789012
SENTRY_DSN="https://xxxxx@xxxx.ingest.us.sentry.io/123456" # Optional
DATABASE_PATH=/path/to/db.sqlite # Optional
PORT=3000 # Optional
···
```bash
SLACK_TOKEN=xoxb-123456789012-123456789012-123456789012-123456789012
SLACK_SIGNING_SECRET=12345678901234567890123456789012
+
NODE_ENV=production
SENTRY_DSN="https://xxxxx@xxxx.ingest.us.sentry.io/123456" # Optional
DATABASE_PATH=/path/to/db.sqlite # Optional
PORT=3000 # Optional
+21
src/index.ts
···
},
}),
)
.get("/", ({ redirect, headers }) => {
// check if its a browser
···
if (e instanceof Error && e.message === "user_not_found")
return error(404, { message: "User not found" });
return error(500, {
message: `Error fetching user from Slack: ${e}`,
});
···
} catch (e) {
if (e instanceof Error && e.message === "user_not_found")
return error(404, { message: "User not found" });
return error(500, {
message: `Error fetching user from Slack: ${e}`,
···
},
}),
)
+
.onError(({ code, error }) => {
+
console.error(error);
+
Sentry.captureException(error);
+
if (code === "VALIDATION") {
+
return error.message;
+
}
+
})
.get("/", ({ redirect, headers }) => {
// check if its a browser
···
if (e instanceof Error && e.message === "user_not_found")
return error(404, { message: "User not found" });
+
Sentry.captureException(e);
+
+
if (e instanceof Error)
+
console.warn(
+
`\x1b[38;5;214m ⚠️ WARN\x1b[0m error on fetching user from slack: \x1b[38;5;208m${e.message}\x1b[0m`,
+
);
+
return error(500, {
message: `Error fetching user from Slack: ${e}`,
});
···
} catch (e) {
if (e instanceof Error && e.message === "user_not_found")
return error(404, { message: "User not found" });
+
+
Sentry.captureException(e);
+
+
if (e instanceof Error)
+
console.warn(
+
`\x1b[38;5;214m ⚠️ WARN\x1b[0m error on fetching user from slack: \x1b[38;5;208m${e.message}\x1b[0m`,
+
);
return error(500, {
message: `Error fetching user from Slack: ${e}`,