Files
pezkuwi-telegram-miniapp/eslint.config.js
T
SatoshiQaziMuhammed 07cd642051 ops: run the Telegram bots and the assistant on vps3 (#46)
* ops: run the Telegram bots and the assistant on vps3

telegram-bot and ask ran on the free cloud project, which paused itself
after a quiet week; every bot went silent and the deploy job failed against
the paused project. They now run in their own edge-runtime container on vps3
(bots/), from /opt/pezkuwi-bots.

Separate from the shared functions runtime because that one verifies a JWT
on every request, which Telegram cannot send, and holds the platform's wallet
keys, which a public bot feeding user text to a language model should not
sit next to. The new runtime holds only the keys the two functions read.

- telegram-bot refuses updates without Telegram's secret-token header
  (TELEGRAM_WEBHOOK_SECRET); the main slot reads TELEGRAM_BOT_TOKEN_MAIN,
  since TELEGRAM_BOT_TOKEN on vps3 is the miniapp's sign-in check.
- nginx keeps the public URL shape:
  supabase.pezkuwichain.io/functions/v1/{telegram-bot,ask}.
- deploy.yml ships them with a new bots-deploy verb on the existing deploy
  key; the host script accepts exactly main, telegram-bot and ask, restarts
  the container and fails unless the bot comes back refusing unsigned updates.
- Registry: _cloud_hosted becomes _hosted_elsewhere; the gate refuses those
  names in the shared volume and reports any copy there as stale.

* ask: send the legacy service key as a bearer token on vps3

The vps3 gateway has no opaque sb_secret keys and honours the service_role JWT
only as a bearer token; sent on apikey alone it reads as anon, the limiter's
count fails, and every question is refused as rate-limited.
2026-10-22 13:51:35 +04:00

184 lines
5.2 KiB
JavaScript

import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import prettier from 'eslint-plugin-prettier';
export default [
js.configs.recommended,
// TypeScript and React files (browser environment)
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: { jsx: true },
},
globals: {
// Browser globals
window: 'readonly',
document: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
fetch: 'readonly',
URLSearchParams: 'readonly',
Map: 'readonly',
Set: 'readonly',
Promise: 'readonly',
navigator: 'readonly',
localStorage: 'readonly',
crypto: 'readonly',
CryptoKey: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
Uint8Array: 'readonly',
ArrayBuffer: 'readonly',
btoa: 'readonly',
atob: 'readonly',
BigInt: 'readonly',
URL: 'readonly',
Blob: 'readonly',
File: 'readonly',
FileReader: 'readonly',
FormData: 'readonly',
Headers: 'readonly',
Request: 'readonly',
Response: 'readonly',
AbortController: 'readonly',
AbortSignal: 'readonly',
Event: 'readonly',
CustomEvent: 'readonly',
EventTarget: 'readonly',
MutationObserver: 'readonly',
ResizeObserver: 'readonly',
IntersectionObserver: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
performance: 'readonly',
queueMicrotask: 'readonly',
structuredClone: 'readonly',
indexedDB: 'readonly',
IDBDatabase: 'readonly',
// Import.meta for Vite
ImportMeta: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescript,
react,
'react-hooks': reactHooks,
prettier,
},
settings: {
react: { version: 'detect' },
},
rules: {
...typescript.configs.recommended.rules,
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'prettier/prettier': 'error',
'no-console': ['warn', { allow: ['warn', 'error'] }],
// Additional rules for better code quality
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'react/display-name': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
// Node.js script files (CommonJS - .js)
{
files: ['scripts/**/*.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
globals: {
// Node.js globals
process: 'readonly',
console: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
Buffer: 'readonly',
setTimeout: 'readonly',
setInterval: 'readonly',
clearTimeout: 'readonly',
clearInterval: 'readonly',
setImmediate: 'readonly',
clearImmediate: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
Promise: 'readonly',
Map: 'readonly',
Set: 'readonly',
BigInt: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
},
},
rules: {
'no-console': 'off', // Allow console in scripts
'no-undef': 'error',
},
},
// Node.js script files (ES Modules - .mjs)
{
files: ['scripts/**/*.mjs'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
// Node.js globals
process: 'readonly',
console: 'readonly',
Buffer: 'readonly',
setTimeout: 'readonly',
setInterval: 'readonly',
clearTimeout: 'readonly',
clearInterval: 'readonly',
setImmediate: 'readonly',
clearImmediate: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
Promise: 'readonly',
Map: 'readonly',
Set: 'readonly',
BigInt: 'readonly',
TextEncoder: 'readonly',
TextDecoder: 'readonly',
fetch: 'readonly',
},
},
rules: {
'no-console': 'off', // Allow console in scripts
'no-undef': 'error',
},
},
// Ignore patterns
{
ignores: [
'dist/**',
'node_modules/**',
'coverage/**',
'supabase/functions/**', // Deno runtime, different globals
'bots/**', // same edge runtime as supabase/functions
'*.config.js',
'*.config.ts',
'.*.js',
'.*.cjs',
],
},
];