a cache for slack profile pictures and emojis

chore: add cron to hopefully fix the emoji experation

Changed files
+13 -2
src
bun.lockb

This is a binary file and will not be displayed.

+1
package.json
···
},
"dependencies": {
"@elysiajs/cors": "^1.1.1",
+
"@elysiajs/cron": "^1.2.0",
"@elysiajs/swagger": "^1.1.6",
"@sentry/bun": "^8.45.0",
"@tqman/nice-logger": "^1.0.7",
+1 -1
src/cache.ts
···
*/
private setupPurgeSchedule() {
// Run purge every hour
-
schedule("0 * * * *", async () => {
+
schedule("45 * * * *", async () => {
await this.purgeExpiredItems();
});
}
+11 -1
src/index.ts
···
import { logger } from "@tqman/nice-logger";
import { swagger } from "@elysiajs/swagger";
import { cors } from "@elysiajs/cors";
+
import { cron } from "@elysiajs/cron";
import { version } from "../package.json";
import { SlackCache } from "./cache";
import { SlackWrapper } from "./slackWrapper";
···
const cache = new SlackCache(
process.env.DATABASE_PATH ?? "./data/cachet.db",
-
24,
+
25,
async () => {
console.log("Fetching emojis from Slack");
const emojis = await slackApp.getEmojiList();
···
.use(
cors({
origin: true,
+
}),
+
)
+
.use(
+
cron({
+
name: "heartbeat",
+
pattern: "0 0 * * *",
+
async run() {
+
await cache.purgeAll();
+
},
}),
)
.use(