import express from 'express';
import { SecureLend } from '@securelend/sdk';
const app = express();
const port = 3000;
const client = new SecureLend({
apiKey: process.env.SECURELEND_API_KEY,
});
app.use(express.json());
app.post('/get-offers', async (req, res) => {
try {
const { amount, term, businessType } = req.body;
if (!amount || !term || !businessType) {
return res.status(400).json({ error: 'Missing required parameters.' });
}
const offers = await client.getLoanOffers({ amount, term, businessType });
res.json(offers);
} catch (error) {
console.error('API Error:', error);
res.status(500).json({ error: 'Failed to fetch loan offers.' });
}
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});