← back to Calendar Agentabrams
server.js
22 lines
// calendar.agentabrams.com — BHV Instagram posting calendar.
// Pin to Pacific so slot times match the Mac2 launchd poster regardless of server TZ
// (Kamatera runs UTC). Must be set before any Date use.
process.env.TZ = 'America/Los_Angeles';
import express from 'express';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { upcoming, stats } from './schedule.mjs';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const app = express();
const PORT = process.env.PORT || 9968;
app.get('/healthz', (_req, res) => res.json({ ok: true, ...stats() }));
app.get('/api/schedule', (req, res) => {
const days = Math.min(60, Math.max(1, parseInt(req.query.days, 10) || 14));
res.json({ generatedAt: new Date().toISOString(), stats: stats(), items: upcoming({ days }) });
});
app.use(express.static(path.join(HERE, 'public')));
app.listen(PORT, () => console.log(`calendar-agentabrams on :${PORT}`));