38 lines
837 B
TypeScript
38 lines
837 B
TypeScript
import { getTutorials } from "../../../shared/services/home/tutorialsService.ts";
|
|
import { Request, Response } from "express";
|
|
|
|
export const tutorialsDataController = async (
|
|
req: Request,
|
|
res: Response
|
|
): Promise<void> => {
|
|
try {
|
|
const { organization = "tutorials" } = req.body;
|
|
if (!organization) {
|
|
res.status(400).json({
|
|
message: "Organization is required",
|
|
});
|
|
return;
|
|
}
|
|
|
|
|
|
const result = await getTutorials({ organization });
|
|
|
|
switch (result?.status) {
|
|
case "Success":
|
|
res.status(200).json({
|
|
tutorials: result.data,
|
|
});
|
|
break;
|
|
default:
|
|
res.status(500).json({
|
|
message: "Internal server error",
|
|
});
|
|
break;
|
|
}
|
|
} catch (error) {
|
|
res.status(500).json({
|
|
message: "Unknown error",
|
|
});
|
|
}
|
|
};
|