ADD: create and get a transaction handlers
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
const catchAsync = require('../../globalErrorHandler/catchAsync')
|
||||
const transactionService = require('./transactionService')
|
||||
|
||||
exports.createTransaction = catchAsync(async (req, res, next) => {
|
||||
const transactions = await transactionService.createTransaction(req.body)
|
||||
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
results: transactions.length,
|
||||
data: transactions,
|
||||
})
|
||||
})
|
||||
|
||||
exports.getUserTransaction = catchAsync(async (req, res, next) => {
|
||||
const transactions = await transactionService.getUserTransaction(req.user._id)
|
||||
|
||||
res.status(200).json({
|
||||
status: 'success',
|
||||
results: transactions.length,
|
||||
data: transactions,
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user