Add neutral AZ API alias and slug resolver
This commit is contained in:
@@ -131,6 +131,36 @@ router.get('/stores', async (req: Request, res: Response) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /api/dutchie-az/stores/slug/:slug
|
||||
* Resolve a store by slug (case-insensitive) or platform_dispensary_id
|
||||
*/
|
||||
router.get('/stores/slug/:slug', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { slug } = req.params;
|
||||
const normalized = slug.toLowerCase();
|
||||
|
||||
const { rows } = await query(
|
||||
`
|
||||
SELECT *
|
||||
FROM dispensaries
|
||||
WHERE lower(slug) = $1
|
||||
OR lower(platform_dispensary_id) = $1
|
||||
LIMIT 1
|
||||
`,
|
||||
[normalized]
|
||||
);
|
||||
|
||||
if (!rows || rows.length === 0) {
|
||||
return res.status(404).json({ error: 'Store not found' });
|
||||
}
|
||||
|
||||
res.json(rows[0]);
|
||||
} catch (error: any) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /api/dutchie-az/stores/:id
|
||||
* Get a single store by ID
|
||||
|
||||
@@ -88,6 +88,9 @@ app.use('/api/parallel-scrape', parallelScrapeRoutes);
|
||||
app.use('/api/schedule', scheduleRoutes);
|
||||
app.use('/api/crawler-sandbox', crawlerSandboxRoutes);
|
||||
app.use('/api/version', versionRoutes);
|
||||
// Vendor-agnostic AZ data pipeline routes (new public surface)
|
||||
app.use('/api/az', dutchieAZRouter);
|
||||
// Legacy alias (kept temporarily for backward compatibility)
|
||||
app.use('/api/dutchie-az', dutchieAZRouter);
|
||||
|
||||
// Public API v1 - External consumer endpoints (WordPress, etc.)
|
||||
|
||||
Reference in New Issue
Block a user