This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1import { SlackApp } from "slack-edge"; 2 3import { takes } from "./features/index"; 4import frontend from "../public/index.html"; 5 6import { t } from "./libs/template"; 7import { blog } from "./libs/Logger"; 8import { version, name } from "../package.json"; 9import { apiRouter, video } from "./features/api"; 10const environment = process.env.NODE_ENV; 11 12import * as Sentry from "@sentry/bun"; 13 14// Check required environment variables 15const requiredVars = [ 16 "SLACK_BOT_TOKEN", 17 "SLACK_SIGNING_SECRET", 18 "SLACK_REVIEW_CHANNEL", 19 "SLACK_LOG_CHANNEL", 20 "SLACK_SPAM_CHANNEL", 21 "SLACK_USER_TOKEN", 22 "API_URL", 23 "SENTRY_DSN", 24] as const; 25const missingVars = requiredVars.filter((varName) => !process.env[varName]); 26 27if (missingVars.length > 0) { 28 throw new Error( 29 `Missing required environment variables: ${missingVars.join(", ")}`, 30 ); 31} 32 33Sentry.init({ 34 dsn: process.env.SENTRY_DSN, 35 environment, 36 release: version, 37}); 38 39console.log( 40 `----------------------------------\n${name} Server\n----------------------------------\n`, 41); 42console.log(`🏗️ Starting ${name}...`); 43console.log("📦 Loading Slack App..."); 44console.log("🔑 Loading environment variables..."); 45 46const slackApp = new SlackApp({ 47 env: { 48 SLACK_BOT_TOKEN: process.env.SLACK_BOT_TOKEN as string, 49 SLACK_SIGNING_SECRET: process.env.SLACK_SIGNING_SECRET as string, 50 SLACK_LOGGING_LEVEL: "INFO", 51 }, 52 startLazyListenerAfterAck: true, 53}); 54const slackClient = slackApp.client; 55 56takes(); 57 58Bun.serve({ 59 port: process.env.PORT || 3000, 60 development: environment === "dev", 61 routes: { 62 "/": frontend, 63 "/user/*": frontend, 64 "/health": new Response("OK"), 65 }, 66 async fetch(request: Request) { 67 const url = new URL(request.url); 68 const path = `/${url.pathname.split("/")[1]}`; 69 70 switch (path) { 71 case "/slack": 72 return slackApp.run(request); 73 case "/api": 74 return apiRouter(url); 75 default: 76 return new Response("404 Not Found", { status: 404 }); 77 } 78 }, 79}); 80 81console.log( 82 `🚀 Server Started in ${ 83 Bun.nanoseconds() / 1000000 84 } milliseconds on version: ${version}!\n\n----------------------------------\n`, 85); 86 87blog( 88 t("app.startup", { 89 environment, 90 }), 91 "start", 92 { 93 channel: process.env.SLACK_SPAM_CHANNEL || "", 94 }, 95); 96 97console.log("\n----------------------------------\n"); 98 99export { slackApp, slackClient, version, name, environment };