const { Faqs } = require('../../models');
const { formatCase } = require('../../util/formatter');

exports.getAllFaqs = async (req, res, next) => {
	try {
		const faqs = await Faqs.findAll({
			order: [['order', 'ASC']],
		});

		return res.status(200).json({
			success: true,
			data: formatCase(faqs.map((faq) => faq.get({ plain: true }))),
		});
	} catch (error) {
		next(error);
	}
};
