A simple Node.js + Express app with a clean UI for summarizing long text via OpenAI. It serves a static frontend from public and exposes POST /api/summarize.
- Install dependencies:
npm install- Set your OpenAI API key (optional for preview mode):
# Windows PowerShell
$env:OPENAI_API_KEY="sk-..."
# macOS/Linux
export OPENAI_API_KEY="sk-..."- Run the server:
npm run devOpen http://localhost:3000.
Without an API key, the app returns a truncated preview summary.
Environment variables:
OPENAI_API_KEY– required for real summariesPORT– optional; defaults to 3000
- New Web Service → Connect repo
- Build Command:
npm install - Start Command:
npm start - Add env var
OPENAI_API_KEY
- Set
OPENAI_API_KEYin project variables - Start command:
npm start
- Use a Node serverless function or deploy as a Node server:
- Framework preset: “Other”
- Build Command:
npm install - Output: N/A (server app)
- Add
OPENAI_API_KEY
POST /api/summarize
- body:
{ "text": string }(min 200 chars) - response:
{ "summary": string }
index.js– Express server and/api/summarizepublic/– static frontend (index.html,stylesheet.css,script.js)
- Client adds loading state, validation, copy/clear, and character counter.
- The server limits JSON size to 1MB. Increase if needed.