tutorial api creation and project changes
This commit is contained in:
@@ -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;
|
||||
|
||||
37
src/api-server/controller/home/tutorialControllers.ts
Normal file
37
src/api-server/controller/home/tutorialControllers.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user