mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
migrated setting routes to typescript
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import AuthUserService from "../services/AuthUserSerice";
|
||||
import AuthUserService from "../services/UserServices/AuthUserSerice";
|
||||
|
||||
const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
const { email, password } = req.body;
|
||||
|
||||
41
backend/src/controllers/SettingController.ts
Normal file
41
backend/src/controllers/SettingController.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import AppError from "../errors/AppError";
|
||||
|
||||
import UpdateSettingService from "../services/SettingServices/UpdateSettingService";
|
||||
import ListSettingsService from "../services/SettingServices/ListSettingsService";
|
||||
// const { getIO } = require("../libs/socket");
|
||||
|
||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||
if (req.user.profile !== "admin") {
|
||||
throw new AppError("Only administrators can access resource.", 403);
|
||||
}
|
||||
|
||||
const settings = await ListSettingsService();
|
||||
|
||||
return res.status(200).json(settings);
|
||||
};
|
||||
|
||||
export const update = async (
|
||||
req: Request,
|
||||
res: Response
|
||||
): Promise<Response> => {
|
||||
if (req.user.profile !== "admin") {
|
||||
throw new AppError("Only administrators can access this route.", 403);
|
||||
}
|
||||
const { settingKey: key } = req.params;
|
||||
const { value } = req.body;
|
||||
|
||||
const setting = await UpdateSettingService({
|
||||
key,
|
||||
value
|
||||
});
|
||||
|
||||
// const io = getIO();
|
||||
// io.emit("settings", {
|
||||
// action: "update",
|
||||
// setting
|
||||
// });
|
||||
|
||||
return res.status(200).json(setting);
|
||||
};
|
||||
@@ -3,11 +3,11 @@ import { Request, Response } from "express";
|
||||
import CheckSettingsHelper from "../helpers/CheckSettingsHelper";
|
||||
import AppError from "../errors/AppError";
|
||||
|
||||
import CreateUserService from "../services/CreateUserService";
|
||||
import ListUsersService from "../services/ListUsersService";
|
||||
import UpdateUserService from "../services/UpdateUserService";
|
||||
import FindUserService from "../services/FindUserService";
|
||||
import DeleteUserService from "../services/DeleteUserService";
|
||||
import CreateUserService from "../services/UserServices/CreateUserService";
|
||||
import ListUsersService from "../services/UserServices/ListUsersService";
|
||||
import UpdateUserService from "../services/UserServices/UpdateUserService";
|
||||
import FindUserService from "../services/UserServices/FindUserService";
|
||||
import DeleteUserService from "../services/UserServices/DeleteUserService";
|
||||
|
||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||
if (req.user.profile !== "admin") {
|
||||
|
||||
Reference in New Issue
Block a user