← back to Ventura Corridor
iter 162: /api/magazine/:id/social-pack.json — programmatic JSON twin of ad-pack.html (5 brief variants + tags + asset URLs)
fcadf64cc9524fc27056a0d7e4241b936fac914b · 2026-05-06 19:42:39 -0700 · SteveStudio2
Files touched
Diff
commit fcadf64cc9524fc27056a0d7e4241b936fac914b
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date: Wed May 6 19:42:39 2026 -0700
iter 162: /api/magazine/:id/social-pack.json — programmatic JSON twin of ad-pack.html (5 brief variants + tags + asset URLs)
---
src/server/index.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/src/server/index.ts b/src/server/index.ts
index c785032..288b08a 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -3330,6 +3330,58 @@ app.get('/api/find', async (req, res) => {
}
});
+// /api/magazine/:id/social-pack.json — JSON shape of the ad-pack page.
+// Programmatic consumers (IG agent, bots) get short/medium/long brief variants
+// + tags + share-card url + audio url + permalink in one call.
+app.get('/api/magazine/:id/social-pack.json', async (req, res) => {
+ try {
+ const id = parseInt(req.params.id, 10);
+ if (!Number.isFinite(id)) return res.status(400).json({ error: 'bad id' });
+ const r = await query(
+ `SELECT mf.id, mf.headline, mf.subhead, mf.editorial, mf.pull_quote, mf.category_tag,
+ mf.published_at,
+ b.name AS biz_name, b.address AS biz_address, b.city, b.zip
+ FROM magazine_features mf JOIN businesses b ON b.id = mf.business_id
+ WHERE mf.id = $1`, [id]
+ );
+ if (r.rowCount === 0) return res.status(404).json({ error: 'not found' });
+ const f = r.rows[0];
+ const baseUrl = process.env.PUBLIC_BASE_URL || 'http://127.0.0.1:9780';
+ const tagline = String(f.subhead || (f.editorial || '').split(/[.!?]\s/)[0] || '').slice(0, 90);
+ const short = String(f.subhead || tagline).slice(0, 90);
+ const medium = (() => {
+ const lede = String(f.editorial || '').split(/(?<=[.!?])\s+/).slice(0, 2).join(' ');
+ return lede.slice(0, 280);
+ })();
+ const long = String(f.editorial || '').slice(0, 540).replace(/\s+\S*$/, '') + '…';
+ const tags = ['#TheCorridor', '#VenturaBoulevard', '#LosAngeles'];
+ if (f.category_tag) tags.push('#' + String(f.category_tag).replace(/[^a-z0-9]/gi, ''));
+ if (f.city) tags.push('#' + String(f.city).replace(/\s+/g, ''));
+
+ res.json({
+ feature_id: f.id,
+ headline: f.headline,
+ biz_name: f.biz_name,
+ category: f.category_tag,
+ city: f.city,
+ permalink: `${baseUrl}/magazine/${id}`,
+ ad_pack_url: `${baseUrl}/magazine/${id}/ad-pack.html`,
+ share_card: `${baseUrl}/share/${id}`,
+ audio_m4a: `${baseUrl}/api/magazine/${id}/audio.m4a`,
+ tags,
+ variants: {
+ short: { text: short, chars: short.length, fits: ['twitter','x','gbp','sms'] },
+ medium: { text: medium, chars: medium.length, fits: ['facebook','instagram','linkedin'] },
+ medium_tags: { text: medium + '\n\n' + tags.join(' '), chars: medium.length + tags.join(' ').length + 2, fits: ['instagram','facebook'] },
+ long: { text: long, chars: long.length, fits: ['newsletter','about-page','press-kit'] },
+ pull_quote: f.pull_quote ? { text: `"${f.pull_quote}"`, chars: f.pull_quote.length + 2, fits: ['hero-callout','standalone-graphic'] } : null,
+ },
+ });
+ } catch (e: any) {
+ res.status(500).json({ error: e.message });
+ }
+});
+
// /magazine/:id/ad-pack.html — copy-ready ad-brief variants for the feature.
// Three lengths: short (Twitter/X / GBP), medium (FB/IG), long (full editorial extract).
// Steve hands this URL to a business owner so they can pick the brief that suits.
← b39e8cf iter 161: /health.html — pipeline-wide one-page status w/ pi
·
back to Ventura Corridor
·
iter 163: /api/magazine/draft-pick-of-the-night + 'Publish n 280b679 →