All materials
shipping-api-server.js
jsshipping-api-server.js
const express = require('express');
const app = express();
const PORT = 4000;
// Third-party shipping API mock
// Receives tracking requests with buyer pricing in URL parameters
app.get('/track', (req, res) => {
const { lot, weight, price, buyer } = req.query;
// Log the request -- in a real system, these URL parameters would appear
// in web server access logs, CDN logs, and potentially cached by intermediaries
console.log(`[SHIPPING] Track request: lot=${lot} weight=${weight} price=${price} buyer=${buyer}`);
res.json({
tracking_id: `SHP-${Date.now()}`,
lot_number: lot || 'unknown',
status: 'in_transit',
estimated_delivery: '2024-03-01',
carrier: 'Caribbean Express Logistics',
origin: 'San Cristobal, Venezuela',
destination: buyer ? `${buyer} warehouse` : 'unknown'
});
});
app.get('/health', (req, res) => {
res.json({ status: 'ok', service: 'Caribbean Express Shipping API' });
});
app.get('/', (req, res) => {
res.json({
service: 'Caribbean Express Shipping API',
version: '2.1',
docs: '/docs',
status: 'operational'
});
});
app.listen(PORT, '0.0.0.0', () => {
console.log(`Shipping API running on port ${PORT}`);
});