diff --git a/src/routes/transfers.js b/src/routes/transfers.js index 01b221fe7..a61bd45bc 100644 --- a/src/routes/transfers.js +++ b/src/routes/transfers.js @@ -1,20 +1,24 @@ -const express = require("express"); -const router = express.Router(); +const express = require('express') +const router = express.Router() -const TransferController = require("../controllers/transfers"); -const authenticate = require("../middleware/auth"); -const createTransaction = require("../middleware/network"); +const TransferController = require('../controllers/transfers') +const authenticate = require('../middleware/auth') +const createTransaction = require('../middleware/network') -router.post("/", authenticate, async (req, res) => { +router.post('/', authenticate, async (req, res) => { try { - const transfer = await TransferController.create(req, res); - const transactionHash = await createTransaction(req.user.wallet_address, req.body.receiver_account_id, req.body.amount); - transfer.transaction_hash = transactionHash; - await transfer.save(); - res.json({ message: "Transfer successful", transfer }); + const transfer = await TransferController.create(req, res) + const transactionHash = await createTransaction( + req.user.wallet_address, + req.body.receiver_account_id, + req.body.amount + ) + transfer.transaction_hash = transactionHash + await transfer.save() + res.json({ message: 'Transfer successful', transfer }) } catch (error) { - res.status(400).json({ message: error.message }); + res.status(400).json({ message: error.message }) } -}); +}) -module.exports = router; +module.exports = router