61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
const catchAsync = require('../../globalErrorHandler/catchAsync')
|
|
const settingService = require('./settingService')
|
|
|
|
exports.getSearchSettings = catchAsync(async (req, res, next) => {
|
|
const settings = await settingService.getSearchSettings()
|
|
|
|
res.status(200).json({
|
|
status: 'success',
|
|
results: settings.length,
|
|
data: settings,
|
|
})
|
|
})
|
|
|
|
exports.getSearchSettingByPage = catchAsync(async (req, res, next) => {
|
|
const setting = await settingService.getSearchSettingByPage(req.params.pageKey)
|
|
|
|
res.status(200).json({
|
|
status: 'success',
|
|
data: setting,
|
|
})
|
|
})
|
|
|
|
exports.updateSearchSetting = catchAsync(async (req, res, next) => {
|
|
const { searchMethod, extraConfig } = req.body
|
|
const setting = await settingService.setSearchMethod(req.params.pageKey, searchMethod, extraConfig)
|
|
|
|
res.status(200).json({
|
|
status: 'success',
|
|
data: setting,
|
|
})
|
|
})
|
|
|
|
exports.bulkUpdateSearchSettings = catchAsync(async (req, res, next) => {
|
|
const { settings } = req.body
|
|
const results = await settingService.bulkUpdateSearchSettings(settings)
|
|
|
|
res.status(200).json({
|
|
status: 'success',
|
|
results: results.length,
|
|
data: results,
|
|
})
|
|
})
|
|
|
|
exports.getSeedStatus = catchAsync(async (req, res, next) => {
|
|
const status = await settingService.getSeedStatus()
|
|
|
|
res.status(200).json({
|
|
status: 'success',
|
|
data: status,
|
|
})
|
|
})
|
|
|
|
exports.seedDatabase = catchAsync(async (req, res, next) => {
|
|
const result = await settingService.seedDatabase(req.user?._id)
|
|
|
|
res.status(200).json({
|
|
status: 'success',
|
|
data: result,
|
|
})
|
|
})
|