tutorial api creation and project changes

This commit is contained in:
2025-05-19 13:18:22 +05:30
parent 9be63d3459
commit d863465030
8 changed files with 71 additions and 14 deletions

View File

@@ -1,10 +1,12 @@
import * as express from "express";
import { recentDataController, searchProjectController, searchTrashProjectController } from "../controller/home/homeControllers.ts";
import { searchTrashProject } from "../../shared/services/home/homeService.ts";
import { tutorialsDataController } from "../controller/home/tutorialControllers.ts";
const homePageRouter = express.Router();
homePageRouter.get("/RecentlyViewed/:userId/:organization", recentDataController);
homePageRouter.get("/searchProjects", searchProjectController);
homePageRouter.get("/searchTrashProjects", searchTrashProjectController);
homePageRouter.get("/tutorials", tutorialsDataController);
export default homePageRouter;

View File

@@ -0,0 +1,37 @@
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",
});
}
};