Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/danielitoCode/AlejoTaller/llms.txt

Use this file to discover all available pages before exploring further.

alejo_publisher is a standard Node.js/Express application. It compiles to plain JavaScript via tsc and runs with node. Any host that can run a Node.js process — Render, Railway, Fly.io, a plain VPS — will work. This guide covers local development first, then a Render deployment.

Local Development

1

Navigate to the service directory

All commands in this guide run from inside the alejo_publisher package directory.
cd function/alejo_publisher
2

Copy the environment file

The repository ships an .env.example with placeholder values. Copy it to create your local .env:
cp .env.example .env
3

Fill in your credentials

Open .env and replace the placeholder values with your actual Pusher app credentials and a chosen API key:
PORT=3000
PUBLISHER_API_KEY=tallerAlejoTestApiKey
PUSHER_APP_ID=your_pusher_app_id
PUSHER_KEY=your_pusher_key
PUSHER_SECRET=your_pusher_secret
PUSHER_CLUSTER=mt1
ALLOW_ORIGIN=*
You can find your Pusher credentials in the App Keys section of the Pusher dashboard after creating or opening an app.
4

Install dependencies

npm install
5

Start the development server

The dev script uses tsx watch, which compiles TypeScript on the fly and restarts on file changes — no separate build step needed.
npm run dev
You should see:
[alejo_publisher] listening on port 3000
6

Verify the service is healthy

In a second terminal, confirm the health endpoint responds:
curl http://localhost:3000/health
Expected response:
{ "ok": true, "service": "alejo_publisher" }

Deploy to Render

1

Connect your GitHub repository to Render

Log in to render.com, go to New → Web Service, and connect the GitHub account that hosts the AlejoTaller monorepo. Authorize Render to access the repository.
2

Create a new Web Service

Select the AlejoTaller repository from the list and click Connect.
3

Set the Root Directory

Under Root Directory, enter:
function/alejo_publisher
Render will treat this subdirectory as the project root, so package.json is resolved correctly.
4

Set the Build Command

npm install && npm run build
npm run build runs tsc -p tsconfig.json, which compiles TypeScript sources into the dist/ folder.
5

Set the Start Command

npm run start
This runs node dist/presentation/http/server.js — the compiled entry point.
6

Add environment variables

In the Environment section, add the following key-value pairs. All variables are required except PORT and ALLOW_ORIGIN, which have defaults.
VariableExample value
PORT3000
PUBLISHER_API_KEY(your secret key)
PUSHER_APP_ID(from Pusher dashboard)
PUSHER_KEY(from Pusher dashboard)
PUSHER_SECRET(from Pusher dashboard)
PUSHER_CLUSTERmt1
ALLOW_ORIGINhttps://your-operator-app.example.com
7

Deploy and verify

Click Create Web Service. Render will run the build command, then start the process. Once the deploy succeeds, visit:
https://your-service.onrender.com/health
A 200 OK response with { "ok": true, "service": "alejo_publisher" } confirms the service is live.
Configure Render’s Health Check Path to /health. Render will poll this path and automatically restart the instance if it stops responding, giving you zero-downtime recovery from crashes.

Environment Variables Reference

The readEnv() function in server.ts reads all variables at startup. Missing required variables throw immediately, so a misconfigured deploy fails fast during boot rather than at runtime.
VariableRequiredDefaultDescription
PORTNo3000TCP port the Express server listens on. Render injects its own PORT automatically.
PUBLISHER_API_KEYYesBearer token that the operator app must send. Requests with a wrong or missing token receive 401.
PUSHER_APP_IDYesPusher application ID, found in the Pusher dashboard under App Keys.
PUSHER_KEYYesPusher public key. Also used by client SDKs to subscribe to channels.
PUSHER_SECRETYesPusher secret key used to sign server-side trigger requests. Never expose this to clients.
PUSHER_CLUSTERYesPusher cluster region (e.g. mt1, eu, ap2). Must match the cluster chosen when the Pusher app was created.
ALLOW_ORIGINNo*CORS allowed origins. A single * permits all origins. For multiple specific origins, provide a comma-separated list: https://app.example.com,https://admin.example.com.
The default PUBLISHER_API_KEY value tallerAlejoTestApiKey is included in .env.example for convenience during local development. This key must not be used in any production or staging environment. Generate a strong random secret (at least 32 characters) and set it as the PUBLISHER_API_KEY before deploying.
Setting ALLOW_ORIGIN=* in production allows any website to call your service from a browser. In production, set ALLOW_ORIGIN to the exact origin(s) of the operator application — for example, https://operator.yourdomain.com. Multiple origins are supported as a comma-separated list.

Scripts Reference

These scripts are defined in package.json and can be run from the function/alejo_publisher directory:
ScriptCommandUse
npm run devtsx watch src/presentation/http/server.tsLocal development with hot reload
npm run buildtsc -p tsconfig.jsonCompile TypeScript to dist/
npm run startnode dist/presentation/http/server.jsRun the compiled build (production)
npm run checktsc -p tsconfig.json --noEmitType-check without emitting files
Run npm run check in CI before building to catch type errors early without producing build artifacts.

Build docs developers (and LLMs) love