WIP: PDS Admin tool to hopefully make it easier to moderate your PDS
0
fork

Configure Feed

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

logger

+205 -18
+3 -1
package.json
··· 5 5 "description": "", 6 6 "main": "index.js", 7 7 "scripts": { 8 - "start": "tsc && node dist/index.js", 8 + "start": "tsc && node dist/index.js | pino-pretty", 9 9 "db:generate": "drizzle-kit generate", 10 10 "db:migrate": "drizzle-kit migrate", 11 11 "db:studio": "drizzle-kit studio" ··· 20 20 "@libsql/client": "^0.17.0", 21 21 "drizzle-orm": "^0.45.1", 22 22 "p-queue": "^9.1.0", 23 + "pino": "^10.3.1", 23 24 "smol-toml": "^1.6.0" 24 25 }, 25 26 "devDependencies": { 26 27 "@types/node": "^25.3.0", 27 28 "drizzle-kit": "^0.31.9", 29 + "pino-pretty": "^13.1.3", 28 30 "typescript": "^5.9.3" 29 31 } 30 32 }
+185 -2
pnpm-lock.yaml
··· 23 23 p-queue: 24 24 specifier: ^9.1.0 25 25 version: 9.1.0 26 + pino: 27 + specifier: ^10.3.1 28 + version: 10.3.1 26 29 smol-toml: 27 30 specifier: ^1.6.0 28 31 version: 1.6.0 ··· 33 36 drizzle-kit: 34 37 specifier: ^0.31.9 35 38 version: 0.31.9 39 + pino-pretty: 40 + specifier: ^13.1.3 41 + version: 13.1.3 36 42 typescript: 37 43 specifier: ^5.9.3 38 44 version: 5.9.3 ··· 428 434 '@neon-rs/load@0.0.4': 429 435 resolution: {integrity: sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==} 430 436 437 + '@pinojs/redact@0.4.0': 438 + resolution: {integrity: sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==} 439 + 431 440 '@standard-schema/spec@1.1.0': 432 441 resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} 433 442 ··· 436 445 437 446 '@types/ws@8.18.1': 438 447 resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} 448 + 449 + atomic-sleep@1.0.0: 450 + resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} 451 + engines: {node: '>=8.0.0'} 439 452 440 453 buffer-from@1.1.2: 441 454 resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} 442 455 456 + colorette@2.0.20: 457 + resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} 458 + 443 459 cross-fetch@4.1.0: 444 460 resolution: {integrity: sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==} 445 461 446 462 data-uri-to-buffer@4.0.1: 447 463 resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} 448 464 engines: {node: '>= 12'} 465 + 466 + dateformat@4.6.3: 467 + resolution: {integrity: sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==} 449 468 450 469 debug@4.4.3: 451 470 resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} ··· 556 575 sqlite3: 557 576 optional: true 558 577 578 + end-of-stream@1.4.5: 579 + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} 580 + 559 581 esbuild-register@3.6.0: 560 582 resolution: {integrity: sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==} 561 583 peerDependencies: ··· 580 602 eventemitter3@5.0.4: 581 603 resolution: {integrity: sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==} 582 604 605 + fast-copy@4.0.2: 606 + resolution: {integrity: sha512-ybA6PDXIXOXivLJK/z9e+Otk7ve13I4ckBvGO5I2RRmBU1gMHLVDJYEuJYhGwez7YNlYji2M2DvVU+a9mSFDlw==} 607 + 608 + fast-safe-stringify@2.1.1: 609 + resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} 610 + 583 611 fetch-blob@3.2.0: 584 612 resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} 585 613 engines: {node: ^12.20 || >= 14.13} ··· 591 619 get-tsconfig@4.13.6: 592 620 resolution: {integrity: sha512-shZT/QMiSHc/YBLxxOkMtgSid5HFoauqCE3/exfsEcwg1WkeqjG+V40yBbBrsD+jW2HDXcs28xOfcbm2jI8Ddw==} 593 621 622 + help-me@5.0.0: 623 + resolution: {integrity: sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==} 624 + 625 + joycon@3.1.1: 626 + resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} 627 + engines: {node: '>=10'} 628 + 594 629 js-base64@3.7.8: 595 630 resolution: {integrity: sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow==} 596 631 ··· 603 638 cpu: [x64, arm64, wasm32, arm] 604 639 os: [darwin, linux, win32] 605 640 641 + minimist@1.2.8: 642 + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} 643 + 606 644 ms@2.1.3: 607 645 resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} 608 646 ··· 623 661 node-fetch@3.3.2: 624 662 resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} 625 663 engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} 664 + 665 + on-exit-leak-free@2.1.2: 666 + resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==} 667 + engines: {node: '>=14.0.0'} 668 + 669 + once@1.4.0: 670 + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} 626 671 627 672 p-queue@9.1.0: 628 673 resolution: {integrity: sha512-O/ZPaXuQV29uSLbxWBGGZO1mCQXV2BLIwUr59JUU9SoH76mnYvtms7aafH/isNSNGwuEfP6W/4xD0/TJXxrizw==} ··· 669 714 pgpass@1.0.5: 670 715 resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} 671 716 717 + pino-abstract-transport@3.0.0: 718 + resolution: {integrity: sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==} 719 + 720 + pino-pretty@13.1.3: 721 + resolution: {integrity: sha512-ttXRkkOz6WWC95KeY9+xxWL6AtImwbyMHrL1mSwqwW9u+vLp/WIElvHvCSDg0xO/Dzrggz1zv3rN5ovTRVowKg==} 722 + hasBin: true 723 + 724 + pino-std-serializers@7.1.0: 725 + resolution: {integrity: sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==} 726 + 727 + pino@10.3.1: 728 + resolution: {integrity: sha512-r34yH/GlQpKZbU1BvFFqOjhISRo1MNx1tWYsYvmj6KIRHSPMT2+yHOEb1SG6NMvRoHRF0a07kCOox/9yakl1vg==} 729 + hasBin: true 730 + 672 731 postgres-array@2.0.0: 673 732 resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} 674 733 engines: {node: '>=4'} ··· 685 744 resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} 686 745 engines: {node: '>=0.10.0'} 687 746 747 + process-warning@5.0.0: 748 + resolution: {integrity: sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==} 749 + 688 750 promise-limit@2.7.0: 689 751 resolution: {integrity: sha512-7nJ6v5lnJsXwGprnGXga4wx6d1POjvi5Qmf1ivTRxTjH4Z/9Czja/UCMLVmB9N93GeWOU93XaFaEt6jbuoagNw==} 690 752 753 + pump@3.0.3: 754 + resolution: {integrity: sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==} 755 + 756 + quick-format-unescaped@4.0.4: 757 + resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} 758 + 759 + real-require@0.2.0: 760 + resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} 761 + engines: {node: '>= 12.13.0'} 762 + 691 763 resolve-pkg-maps@1.0.0: 692 764 resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} 693 765 766 + safe-stable-stringify@2.5.0: 767 + resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} 768 + engines: {node: '>=10'} 769 + 770 + secure-json-parse@4.1.0: 771 + resolution: {integrity: sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==} 772 + 694 773 smol-toml@1.6.0: 695 774 resolution: {integrity: sha512-4zemZi0HvTnYwLfrpk/CF9LOd9Lt87kAt50GnqhMpyF9U3poDAP2+iukq2bZsO/ufegbYehBkqINbsWxj4l4cw==} 696 775 engines: {node: '>= 18'} 776 + 777 + sonic-boom@4.2.1: 778 + resolution: {integrity: sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==} 697 779 698 780 source-map-support@0.5.21: 699 781 resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} ··· 706 788 resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} 707 789 engines: {node: '>= 10.x'} 708 790 791 + strip-json-comments@5.0.3: 792 + resolution: {integrity: sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==} 793 + engines: {node: '>=14.16'} 794 + 795 + thread-stream@4.0.0: 796 + resolution: {integrity: sha512-4iMVL6HAINXWf1ZKZjIPcz5wYaOdPhtO8ATvZ+Xqp3BTdaqtAwQkNmKORqcIo5YkQqGXq5cwfswDwMqqQNrpJA==} 797 + engines: {node: '>=20'} 798 + 709 799 tr46@0.0.3: 710 800 resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} 711 801 ··· 733 823 734 824 whatwg-url@5.0.0: 735 825 resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} 826 + 827 + wrappy@1.0.2: 828 + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} 736 829 737 830 ws@8.19.0: 738 831 resolution: {integrity: sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==} ··· 1024 1117 1025 1118 '@neon-rs/load@0.0.4': {} 1026 1119 1120 + '@pinojs/redact@0.4.0': {} 1121 + 1027 1122 '@standard-schema/spec@1.1.0': {} 1028 1123 1029 1124 '@types/node@25.3.0': ··· 1033 1128 '@types/ws@8.18.1': 1034 1129 dependencies: 1035 1130 '@types/node': 25.3.0 1131 + 1132 + atomic-sleep@1.0.0: {} 1036 1133 1037 1134 buffer-from@1.1.2: {} 1038 1135 1136 + colorette@2.0.20: {} 1137 + 1039 1138 cross-fetch@4.1.0: 1040 1139 dependencies: 1041 1140 node-fetch: 2.7.0 ··· 1044 1143 1045 1144 data-uri-to-buffer@4.0.1: {} 1046 1145 1146 + dateformat@4.6.3: {} 1147 + 1047 1148 debug@4.4.3: 1048 1149 dependencies: 1049 1150 ms: 2.1.3 ··· 1064 1165 '@libsql/client': 0.17.0 1065 1166 kysely: 0.22.0 1066 1167 pg: 8.18.0 1168 + 1169 + end-of-stream@1.4.5: 1170 + dependencies: 1171 + once: 1.4.0 1067 1172 1068 1173 esbuild-register@3.6.0(esbuild@0.25.12): 1069 1174 dependencies: ··· 1132 1237 1133 1238 eventemitter3@5.0.4: {} 1134 1239 1240 + fast-copy@4.0.2: {} 1241 + 1242 + fast-safe-stringify@2.1.1: {} 1243 + 1135 1244 fetch-blob@3.2.0: 1136 1245 dependencies: 1137 1246 node-domexception: 1.0.0 ··· 1145 1254 dependencies: 1146 1255 resolve-pkg-maps: 1.0.0 1147 1256 1257 + help-me@5.0.0: {} 1258 + 1259 + joycon@3.1.1: {} 1260 + 1148 1261 js-base64@3.7.8: {} 1149 1262 1150 1263 kysely@0.22.0: ··· 1165 1278 '@libsql/linux-x64-musl': 0.5.22 1166 1279 '@libsql/win32-x64-msvc': 0.5.22 1167 1280 1281 + minimist@1.2.8: {} 1282 + 1168 1283 ms@2.1.3: {} 1169 1284 1170 1285 node-domexception@1.0.0: {} ··· 1179 1294 fetch-blob: 3.2.0 1180 1295 formdata-polyfill: 4.0.10 1181 1296 1297 + on-exit-leak-free@2.1.2: {} 1298 + 1299 + once@1.4.0: 1300 + dependencies: 1301 + wrappy: 1.0.2 1302 + 1182 1303 p-queue@9.1.0: 1183 1304 dependencies: 1184 1305 eventemitter3: 5.0.4 ··· 1232 1353 split2: 4.2.0 1233 1354 optional: true 1234 1355 1356 + pino-abstract-transport@3.0.0: 1357 + dependencies: 1358 + split2: 4.2.0 1359 + 1360 + pino-pretty@13.1.3: 1361 + dependencies: 1362 + colorette: 2.0.20 1363 + dateformat: 4.6.3 1364 + fast-copy: 4.0.2 1365 + fast-safe-stringify: 2.1.1 1366 + help-me: 5.0.0 1367 + joycon: 3.1.1 1368 + minimist: 1.2.8 1369 + on-exit-leak-free: 2.1.2 1370 + pino-abstract-transport: 3.0.0 1371 + pump: 3.0.3 1372 + secure-json-parse: 4.1.0 1373 + sonic-boom: 4.2.1 1374 + strip-json-comments: 5.0.3 1375 + 1376 + pino-std-serializers@7.1.0: {} 1377 + 1378 + pino@10.3.1: 1379 + dependencies: 1380 + '@pinojs/redact': 0.4.0 1381 + atomic-sleep: 1.0.0 1382 + on-exit-leak-free: 2.1.2 1383 + pino-abstract-transport: 3.0.0 1384 + pino-std-serializers: 7.1.0 1385 + process-warning: 5.0.0 1386 + quick-format-unescaped: 4.0.4 1387 + real-require: 0.2.0 1388 + safe-stable-stringify: 2.5.0 1389 + sonic-boom: 4.2.1 1390 + thread-stream: 4.0.0 1391 + 1235 1392 postgres-array@2.0.0: 1236 1393 optional: true 1237 1394 ··· 1246 1403 xtend: 4.0.2 1247 1404 optional: true 1248 1405 1406 + process-warning@5.0.0: {} 1407 + 1249 1408 promise-limit@2.7.0: {} 1250 1409 1410 + pump@3.0.3: 1411 + dependencies: 1412 + end-of-stream: 1.4.5 1413 + once: 1.4.0 1414 + 1415 + quick-format-unescaped@4.0.4: {} 1416 + 1417 + real-require@0.2.0: {} 1418 + 1251 1419 resolve-pkg-maps@1.0.0: {} 1252 1420 1421 + safe-stable-stringify@2.5.0: {} 1422 + 1423 + secure-json-parse@4.1.0: {} 1424 + 1253 1425 smol-toml@1.6.0: {} 1426 + 1427 + sonic-boom@4.2.1: 1428 + dependencies: 1429 + atomic-sleep: 1.0.0 1254 1430 1255 1431 source-map-support@0.5.21: 1256 1432 dependencies: ··· 1259 1435 1260 1436 source-map@0.6.1: {} 1261 1437 1262 - split2@4.2.0: 1263 - optional: true 1438 + split2@4.2.0: {} 1439 + 1440 + strip-json-comments@5.0.3: {} 1441 + 1442 + thread-stream@4.0.0: 1443 + dependencies: 1444 + real-require: 0.2.0 1264 1445 1265 1446 tr46@0.0.3: {} 1266 1447 ··· 1280 1461 dependencies: 1281 1462 tr46: 0.0.3 1282 1463 webidl-conversions: 3.0.1 1464 + 1465 + wrappy@1.0.2: {} 1283 1466 1284 1467 ws@8.19.0: {} 1285 1468
+6 -9
src/handlers/handleNewLabel.ts
··· 1 1 import type { Label } from "@atcute/atproto/types/label/defs"; 2 2 import type { LabelerConfig } from "../types/settings.js"; 3 + import { logger } from "../logger.js"; 3 4 4 5 export const handleNewLabel = async (config: LabelerConfig, label: Label) => { 5 6 // TODO: MAKE SURE TO CHECK NEG 6 - console.log(`From: ${config.host}`); 7 + logger.info({ host: config.host }, "From"); 7 8 8 9 await new Promise((r) => setTimeout(r, 2000)); 9 10 10 11 if (config.labels[label.val]) { 11 - console.log( 12 - `Listed label found. Performing the action: ${config.labels[label.val]?.action}`, 12 + logger.info( 13 + { action: config.labels[label.val]?.action }, 14 + "Listed label found. Performing the action", 13 15 ); 14 - console.log("\n"); 15 16 } 16 - console.log("Label from: ", label.src); 17 - console.log("Label: ", label.val); 18 - console.log("Label for: ", label.uri); 19 - console.log("neg:", label.neg); 20 - console.log("\n"); 17 + logger.info({ src: label.src, val: label.val, uri: label.uri, neg: label.neg }, "Label"); 21 18 };
+3 -2
src/handlers/lablerSubscriber.ts
··· 3 3 import { ComAtprotoLabelSubscribeLabels } from "@atcute/atproto"; 4 4 import type PQueue from "p-queue"; 5 5 import { handleNewLabel } from "./handleNewLabel.js"; 6 + import { logger } from "../logger.js"; 6 7 7 8 export const labelerSubscriber = async ( 8 9 config: LabelerConfig, ··· 13 14 nsid: ComAtprotoLabelSubscribeLabels.mainSchema, 14 15 }); 15 16 16 - console.log(`Listening to ${config.host}`); 17 + logger.info({ host: config.host }, "Listening"); 17 18 for await (const message of subscription) { 18 19 switch (message.$type) { 19 20 case "com.atproto.label.subscribeLabels#info": { 20 - console.log("commit:", message); 21 + logger.info({ message }, "commit"); 21 22 break; 22 23 } 23 24 case "com.atproto.label.subscribeLabels#labels": {
+5 -4
src/index.ts
··· 5 5 import PQueue from "p-queue"; 6 6 import { labelerSubscriber } from "./handlers/lablerSubscriber.js"; 7 7 import type { Settings } from "./types/settings.js"; 8 + import { logger } from "./logger.js"; 8 9 9 10 const queue = new PQueue({ concurrency: 2 }); 10 11 ··· 27 28 28 29 // --- Graceful shutdown --- 29 30 async function shutdown(signal: string) { 30 - console.log(`\nReceived ${signal}, shutting down...`); 31 + logger.info(`Received ${signal}, shutting down...`); 31 32 32 33 // TODO maybe should make sure the websockets close here? 33 34 34 35 // Drain all queues in parallel 35 - console.log("Draining the queue..."); 36 + logger.info("Draining the queue..."); 36 37 await queue.onIdle(); 37 38 38 - console.log("Clean shutdown complete."); 39 + logger.info("Clean shutdown complete."); 39 40 process.exit(0); 40 41 } 41 42 ··· 43 44 process.on("SIGINT", () => shutdown("SIGINT")); 44 45 45 46 process.on("unhandledRejection", (reason) => { 46 - console.error("Unhandled rejection:", reason); 47 + logger.error({ reason }, "Unhandled rejection"); 47 48 }); 48 49 49 50 Promise.all(
+3
src/logger.ts
··· 1 + import pino from "pino"; 2 + 3 + export const logger = pino();