-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (29 loc) · 938 Bytes
/
server.js
File metadata and controls
36 lines (29 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express');
const bodyParser = require('body-parser');
const plaid = require('plaid');
// Import the accounts router
const accountsRouter = require('./accounts-api');
const app = express();
// Middleware to parse JSON
app.use(bodyParser.json());
// Mount the accounts router at /accounts
app.use('/accounts', accountsRouter);
// Example Plaid endpoint (leave as is if you use it)
app.post('/api/public_token', async (req, res) => {
try {
const publicToken = req.body.public_token;
// ... your Plaid logic here ...
res.json({ success: true });
} catch (err) {
console.error(err);
res.status(401).json({ error: err.message || "Unauthorized" });
}
});
// Optional: Root route for health check
app.get('/', (req, res) => {
res.send('API server is running');
});
// Start the server on port 3001
app.listen(3001, () => {
console.log("Backend running on http://localhost:3001");
});