New
This commit is contained in:
parent
fb7d447648
commit
ef1a963c7f
10
server.js
10
server.js
@ -36,14 +36,13 @@ app.get('/free-access/:shop', (req, res) => {
|
|||||||
// ── BACKFILL: Re-run fulfillment service + locationId for shops that have null ─
|
// ── BACKFILL: Re-run fulfillment service + locationId for shops that have null ─
|
||||||
// Hit: GET /admin/fix-location → runs all shops with null locationId
|
// Hit: GET /admin/fix-location → runs all shops with null locationId
|
||||||
// Hit: GET /admin/fix-location/:shop → runs one specific shop
|
// Hit: GET /admin/fix-location/:shop → runs one specific shop
|
||||||
app.get('/admin/fix-location/:shop?', async (req, res) => {
|
async function runFixLocation(req, res) {
|
||||||
const { createFulfillmentService } = require('./fulfillmentService');
|
|
||||||
const stores = listTokens();
|
const stores = listTokens();
|
||||||
const targetShop = req.params.shop ? decodeURIComponent(req.params.shop).toLowerCase().trim() : null;
|
const targetShop = req.params.shop ? decodeURIComponent(req.params.shop).toLowerCase().trim() : null;
|
||||||
|
|
||||||
const toFix = Object.entries(stores).filter(([shop, record]) => {
|
const toFix = Object.entries(stores).filter(([shop, record]) => {
|
||||||
if (targetShop) return shop === targetShop;
|
if (targetShop) return shop === targetShop;
|
||||||
return !record.locationId; // only null locationId shops
|
return !record.locationId;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (toFix.length === 0) {
|
if (toFix.length === 0) {
|
||||||
@ -69,7 +68,10 @@ app.get('/admin/fix-location/:shop?', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.json({ fixed: results.filter(r => r.status === 'fixed').length, total: toFix.length, results });
|
res.json({ fixed: results.filter(r => r.status === 'fixed').length, total: toFix.length, results });
|
||||||
});
|
}
|
||||||
|
|
||||||
|
app.get('/admin/fix-location', runFixLocation);
|
||||||
|
app.get('/admin/fix-location/:shop', runFixLocation);
|
||||||
|
|
||||||
// ── PUBLIC CHAT ENDPOINTS (for customer widget) ──────────────────────────────
|
// ── PUBLIC CHAT ENDPOINTS (for customer widget) ──────────────────────────────
|
||||||
// widget.js MUST be before /chat/:shop — otherwise Express treats "widget.js" as the :shop param
|
// widget.js MUST be before /chat/:shop — otherwise Express treats "widget.js" as the :shop param
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user