-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
39 lines (26 loc) · 906 Bytes
/
index.mjs
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
37
38
import dotenv from 'dotenv'
dotenv.config();
import express from 'express'
import { Farmerbot, Financebot, getCredit } from './controllers/controller.mjs';
import { verifyToken } from './middleware/middleware.mjs';
const app = express()
const loanApplicants = []
app.use(express.json());
// app.use(verifyToken)
app.get('/farmer/:prompt', Farmerbot)
app.get('/finance/:bankName/:prompt', Financebot)
app.get('/credit', getCredit);
app.post('/applyLoan', (req, res) => {
const name = req.body.name;
const loanAmount = req.body.loanAmount;
const location = req.body.location;
const crop = req.body.crop;
const risk = req.body.risk;
loanApplicants.push({ name, loanAmount, risk, location, crop });
})
app.get('/getLoans', (req, res) => {
res.send(loanApplicants)
})
app.listen(process.env.PORT, () => {
console.log(`Server running on port ${process.env.PORT}`)
})