Spaces:
Sleeping
Sleeping
Download backend/src/modules/projects/projects.controller.ts from moustafa7/protofolio: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/backend/src/modules/projects/projects.controller.ts
- Command line
-
hf download hf://spaces/moustafa7/protofolio/backend/src/modules/projects/projects.controller.ts
-
curl -L -o projects.controller.ts https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/backend/src/modules/projects/projects.controller.ts
1.55 kB
| import { Response } from "express"; | |
| import { ProjectsService } from "./projects.service"; | |
| import { ApiResponse } from "../../utils/apiResponse"; | |
| import { AuthRequest } from "../../types"; | |
| const projectsService = new ProjectsService(); | |
| export class ProjectsController { | |
| async getAll(req: any, res: Response) { | |
| const result = await projectsService.getAll(req.query); | |
| return ApiResponse.paginated(res, result.projects, result.total, result.page, result.limit); | |
| } | |
| async getAllAdmin(req: AuthRequest, res: Response) { | |
| const projects = await projectsService.getAllAdmin(); | |
| return ApiResponse.success(res, projects); | |
| } | |
| async getById(req: any, res: Response) { | |
| const project = await projectsService.getById(req.params.id); | |
| return ApiResponse.success(res, project); | |
| } | |
| async create(req: AuthRequest, res: Response) { | |
| const project = await projectsService.create(req.body); | |
| return ApiResponse.success(res, project, "Project created", 201); | |
| } | |
| async update(req: AuthRequest, res: Response) { | |
| const project = await projectsService.update(req.params.id, req.body); | |
| return ApiResponse.success(res, project, "Project updated"); | |
| } | |
| async delete(req: AuthRequest, res: Response) { | |
| await projectsService.delete(req.params.id); | |
| return ApiResponse.success(res, null, "Project deleted"); | |
| } | |
| async togglePublish(req: AuthRequest, res: Response) { | |
| const project = await projectsService.togglePublish(req.params.id); | |
| return ApiResponse.success(res, project, "Publish status toggled"); | |
| } | |
| } | |