ApiSquare includes several Node.js scripts for one-off setup and maintenance tasks. None of these scripts are part of the production application — they are run locally from the project root before or after deployment. All scripts callDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shadownrx/apisquare/llms.txt
Use this file to discover all available pages before exploring further.
require('dotenv').config() at startup, so they automatically load environment variables from a .env or .env.local file without any extra flags.
setup-webhook.js — Register the Telegram Webhook
Registers your deployment URL as the Telegram webhook endpoint. Telegram will POST every bot update to this URL going forward.
- Reads
TELEGRAM_TOKENfrom the environment (loaded viadotenv) - Accepts the target webhook URL as a positional command-line argument
- POSTs to
https://api.telegram.org/bot{token}/setWebhookusingaxios - Exits with code
1and prints an error if the token is missing, no URL is provided, or the Telegram API returns a failure
verificar-webhook.js — Check Current Webhook Status
Queries the Telegram Bot API for the currently registered webhook and prints a summary of its status. Useful for diagnosing delivery failures or confirming that the correct URL is active.
- The currently configured webhook URL (or
Ningunaif none is set) - The number of pending updates queued for delivery
- The last error message reported by Telegram, if any
TELEGRAM_TOKEN from the environment and calls getWebhookInfo via a GET request. No arguments are required.
configurar-webhook-facil.js — Alternative Webhook Setup
A simplified alternative to setup-webhook.js that has the target URL hardcoded in the script rather than read from a command-line argument.
https://apisquare.vercel.app/api/webhook by default and is intended for use when you want a quick, argument-free registration against a stable production URL. It prints the token prefix (first 10 characters) before making the request so you can confirm the correct bot is being configured.
If you are deploying to a custom domain or a different Vercel project URL, edit the
WEBHOOK_URL constant at the top of configurar-webhook-facil.js before running it, or use setup-webhook.js instead, which accepts the URL as a command-line argument.scripts/generate-hash.js — Hash an Admin Password with bcrypt
Generates a bcrypt hash of a plain-text password for use as the ADMIN_PASSWORD environment variable. ApiSquare’s admin login route detects the $2b$ prefix and uses bcrypt.compare() to validate credentials at runtime — the plain-text password is never stored anywhere.
bcryptjs with a cost factor of 10.
Example output:
ADMIN_PASSWORD=... line into your .env.local for local development, or paste just the hash value when setting the variable via vercel env add ADMIN_PASSWORD production.
scripts/get-google-refresh-token.js — Obtain a Google OAuth2 Refresh Token
A one-time interactive script that walks you through the Google OAuth2 consent flow and exchanges an authorization code for a long-lived refresh token. This token is required for ApiSquare’s Google Calendar integration.
- Constructs an OAuth2 authorization URL scoped to
https://www.googleapis.com/auth/calendarusing the configuredGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET - Prints the URL and instructs you to open it in a browser; after you grant access, Google redirects to
http://localhost:3000with acodequery parameter - Prompts you to paste that authorization code into the terminal, exchanges it for tokens, and prints:
This script is for one-time setup only. The refresh token it produces is long-lived and does not expire unless access is revoked. Store it as a Vercel environment variable rather than committing it to your repository.