Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
// /components/contactInquiries/contactInquiryController.js
|
|
|
|
const catchAsync = require('../../utils/catchAsync');
|
|
const contactInquiryService = require('./contactInquiryService');
|
|
const { successResponse, listResponse } = require('../../utils/apiResponse');
|
|
|
|
exports.create = catchAsync(async (req, res) => {
|
|
const inquiry = await contactInquiryService.createInquiry(req.body);
|
|
return successResponse(res, 201, 'Contact inquiry submitted successfully', inquiry);
|
|
});
|
|
|
|
exports.getAll = catchAsync(async (req, res) => {
|
|
const { data, meta } = await contactInquiryService.getAllInquiries(req.query);
|
|
return listResponse(res, 200, data, meta);
|
|
});
|
|
|
|
exports.getOne = catchAsync(async (req, res) => {
|
|
const inquiry = await contactInquiryService.getInquiryById(req.params.id);
|
|
return successResponse(res, 200, 'Contact inquiry retrieved successfully', inquiry);
|
|
});
|
|
|
|
exports.update = catchAsync(async (req, res) => {
|
|
const inquiry = await contactInquiryService.updateInquiry(req.params.id, req.body);
|
|
return successResponse(res, 200, 'Contact inquiry updated successfully', inquiry);
|
|
});
|