mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
feat: added settings api on beackend
This commit is contained in:
23
backend/src/controllers/SettingController.js
Normal file
23
backend/src/controllers/SettingController.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const Sequelize = require("sequelize");
|
||||
|
||||
const Setting = require("../models/Setting");
|
||||
|
||||
exports.index = async (req, res) => {
|
||||
const settings = await Setting.findAll();
|
||||
|
||||
return res.status(200).json(settings);
|
||||
};
|
||||
|
||||
exports.update = async (req, res) => {
|
||||
const { settingKey } = req.params;
|
||||
|
||||
const setting = await Setting.findByPk(settingKey);
|
||||
|
||||
if (!setting) {
|
||||
return res.status(400).json({ error: "No setting found with this ID" });
|
||||
}
|
||||
|
||||
await setting.update(req.body);
|
||||
|
||||
return res.status(200).json(setting);
|
||||
};
|
||||
Reference in New Issue
Block a user