Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ BOT_POLLING=false
## GitHub Application variables
#Personal GitHub token
GITHUB_TOKEN=
## GitHub organization to receive events from
## GitHub organization to receive events from
GITHUB_ORG_NAME=fullstacksjs
## Shared secret for GitHub webhook
GITHUB_WEBHOOK_SECRET=

# Database variables
DB_FILE_PATH="file:database.sqlite"
DB_FILE_PATH="file:database.sqlite"

# Logger variables
LOG_LEVEL=info
LOG_FILE_PATH="logs/app.log"
LOG_TELEGRAM_LEVEL=info
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules/
!.env.example

*.sqlite

logs/
1 change: 1 addition & 0 deletions cspell-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ libsql
listcontributors
listrepos
lyja
multistream
nodenext
pipefail
removerepo
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ services:
- .env
volumes:
- ./data:/app/data
- ./logs:/app/logs
restart: on-failure:16
11 changes: 10 additions & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { defineConfig } from "@fullstacksjs/eslint-config";

export default defineConfig({ esm: true, node: true, strict: true });
export default defineConfig({
esm: true,
node: true,
strict: true,
rules: {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
},
});
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"#github": [
"./src/lib/github/index.ts"
],
"#logger": [
"./src/lib/logger/index.ts"
],
"#webhooks": [
"./src/lib/github/webhooks/index.ts"
],
Expand Down Expand Up @@ -52,6 +55,7 @@
"grammy": "1.38.3",
"hono": "4.10.6",
"octokit": "5.0.5",
"pino": "10.3.1",
"zod": "4.1.12"
},
"devDependencies": {
Expand Down
92 changes: 92 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export async function createApi() {
});

if (!payload.success) {
// eslint-disable-next-line no-console
console.error("Invalid payload:", payload.error);
await reportWebhookError(payload.error, {
reportWebhookError(payload.error, {
eventId: deliveryId,
eventName,
source: "request_validation",
Expand All @@ -45,7 +43,7 @@ export async function createApi() {
try {
await webhooks.verifyAndReceive(payload.data);
} catch (error) {
await reportWebhookError(error, {
reportWebhookError(error, {
eventId: payload.data.id,
eventName: payload.data.name,
source: "request_processing",
Expand Down
5 changes: 5 additions & 0 deletions src/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { autoRetry } from "@grammyjs/auto-retry";
import { I18n } from "@grammyjs/i18n";
import { limit } from "@grammyjs/ratelimiter";
import { config } from "#config";
import { botLogger } from "#logger";
import { Bot as GrammyBot } from "grammy";

import type { HelperContext } from "./middleware/helpers.ts";
Expand Down Expand Up @@ -90,6 +91,10 @@ export class Bot extends GrammyBot<BotContext> {
this.filter(isAdmin).use(adminCommands);

this.api.config.use(autoRetry({ maxRetryAttempts: 2 }));

this.catch(({ error, ctx }) => {
botLogger.error({ err: error, updateId: ctx.update.update_id, chatId: ctx.chat?.id }, "unhandled bot error");
});
}

/**
Expand Down
Loading
Loading