refactor: nambahin role mentor di admin account dan ngeremove max_member di project
This commit is contained in:
@@ -2,6 +2,7 @@ const express = require('express');
|
||||
const { projectController } = require('../modules/project');
|
||||
const { verifyJWT } = require('../middleware/verifyJWT');
|
||||
const isAdmin = require('../middleware/isAdmin');
|
||||
const isMentorOrAdmin = require('../middleware/isMentorOrAdmin');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -33,9 +34,6 @@ const router = express.Router();
|
||||
* type: string
|
||||
* format: date
|
||||
* example: 2026-08-10
|
||||
* max_members:
|
||||
* type: integer
|
||||
* example: 8
|
||||
* status:
|
||||
* type: string
|
||||
* enum: [active, completed, archived]
|
||||
@@ -103,6 +101,352 @@ const router = express.Router();
|
||||
* type: string
|
||||
* enum: [active, completed, archived]
|
||||
* example: completed
|
||||
* ProjectAdminSummary:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* full_name:
|
||||
* type: string
|
||||
* example: Admin One
|
||||
* email:
|
||||
* type: string
|
||||
* example: admin1@internify.com
|
||||
* profile_picture:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: /uploads/admin-profile.png
|
||||
* professional_bio:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: Senior Program Manager at Internify.
|
||||
* ProjectListItem:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* project_icon:
|
||||
* type: string
|
||||
* example: code
|
||||
* project_name:
|
||||
* type: string
|
||||
* example: Internify Platform Dev
|
||||
* description:
|
||||
* type: string
|
||||
* example: Upgrading the core Internify platform backend and web client.
|
||||
* start_date:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-07-15T00:00:00.000Z
|
||||
* end_date:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-10-15T00:00:00.000Z
|
||||
* status:
|
||||
* type: string
|
||||
* example: active
|
||||
* admin:
|
||||
* $ref: '#/components/schemas/ProjectAdminSummary'
|
||||
* total_members:
|
||||
* type: integer
|
||||
* example: 5
|
||||
* total_tasks:
|
||||
* type: integer
|
||||
* example: 3
|
||||
* created_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* ProjectMemberUser:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* full_name:
|
||||
* type: string
|
||||
* example: Rafi Athallah
|
||||
* email:
|
||||
* type: string
|
||||
* example: rafi@student.com
|
||||
* professional_bio:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: Backend developer intern
|
||||
* position:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: Web Developer
|
||||
* kelompok_peminatan:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: Software Engineering
|
||||
* ProjectMemberItem:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* id_user:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* status:
|
||||
* type: string
|
||||
* example: active
|
||||
* user:
|
||||
* $ref: '#/components/schemas/ProjectMemberUser'
|
||||
* created_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* ProjectTaskItem:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* title:
|
||||
* type: string
|
||||
* example: Database Setup
|
||||
* description:
|
||||
* type: string
|
||||
* example: Setup database schema and write initial seed script.
|
||||
* deadline_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-08-01T00:00:00.000Z
|
||||
* submission_type:
|
||||
* type: string
|
||||
* enum: [file_upload, url_link]
|
||||
* example: url_link
|
||||
* created_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* ProjectDetail:
|
||||
* allOf:
|
||||
* - $ref: '#/components/schemas/ProjectListItem'
|
||||
* - type: object
|
||||
* properties:
|
||||
* members:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/ProjectMemberItem'
|
||||
* tasks:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/ProjectTaskItem'
|
||||
* ProjectListResponse:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/ProjectListItem'
|
||||
* message:
|
||||
* type: string
|
||||
* example: Projects retrieved successfully
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* ProjectDetailResponse:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* data:
|
||||
* $ref: '#/components/schemas/ProjectDetail'
|
||||
* message:
|
||||
* type: string
|
||||
* example: Project detail retrieved successfully
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* InternListItem:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* name:
|
||||
* type: string
|
||||
* example: Rafi Athallah
|
||||
* email:
|
||||
* type: string
|
||||
* example: rafi@student.com
|
||||
* projectName:
|
||||
* type: string
|
||||
* example: Internify Platform Dev
|
||||
* projectId:
|
||||
* type: integer
|
||||
* nullable: true
|
||||
* example: 1
|
||||
* role:
|
||||
* type: string
|
||||
* example: Web Developer
|
||||
* isAssignedByMentor:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* avatar:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: null
|
||||
* InternListResponse:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/InternListItem'
|
||||
* message:
|
||||
* type: string
|
||||
* example: Interns retrieved successfully
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* MyTaskItem:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* id_project:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* project_name:
|
||||
* type: string
|
||||
* example: Internify Platform Dev
|
||||
* project_icon:
|
||||
* type: string
|
||||
* example: code
|
||||
* title:
|
||||
* type: string
|
||||
* example: Database Setup
|
||||
* description:
|
||||
* type: string
|
||||
* example: Setup database schema and write initial seed script.
|
||||
* deadline_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-08-01T00:00:00.000Z
|
||||
* submission_type:
|
||||
* type: string
|
||||
* enum: [file_upload, url_link]
|
||||
* example: url_link
|
||||
* submission_status:
|
||||
* type: string
|
||||
* enum: [submitted, not_submitted]
|
||||
* example: submitted
|
||||
* submission_details:
|
||||
* type: object
|
||||
* nullable: true
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* file_path:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: null
|
||||
* url_link:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* example: https://github.com/rafiathallah3
|
||||
* submitted_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-07-20T10:00:00.000Z
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-07-20T10:00:00.000Z
|
||||
* MyTaskListResponse:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/MyTaskItem'
|
||||
* message:
|
||||
* type: string
|
||||
* example: Intern tasks retrieved successfully
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* AssignMemberResponse:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* id_project:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* id_user:
|
||||
* type: integer
|
||||
* example: 2
|
||||
* status:
|
||||
* type: string
|
||||
* example: active
|
||||
* created_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* example: 2026-06-10T10:00:00.000Z
|
||||
* message:
|
||||
* type: string
|
||||
* example: Member assigned successfully
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 200
|
||||
* ErrorResponse:
|
||||
* type: object
|
||||
* properties:
|
||||
* status:
|
||||
* type: boolean
|
||||
* example: false
|
||||
* data:
|
||||
* nullable: true
|
||||
* example: null
|
||||
* message:
|
||||
* type: string
|
||||
* example: Validation error
|
||||
* code:
|
||||
* type: integer
|
||||
* example: 417
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -136,7 +480,7 @@ const router = express.Router();
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.post('/add', verifyJWT, isAdmin, projectController.createProject);
|
||||
router.post('/add', verifyJWT, isMentorOrAdmin, projectController.createProject);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -238,7 +582,7 @@ router.get('/get/:id', verifyJWT, projectController.getProjectById);
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.patch('/update/:id', verifyJWT, isAdmin, projectController.updateProject);
|
||||
router.patch('/update/:id', verifyJWT, isMentorOrAdmin, projectController.updateProject);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -269,7 +613,7 @@ router.patch('/update/:id', verifyJWT, isAdmin, projectController.updateProject)
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.delete('/delete/:id', verifyJWT, isAdmin, projectController.archiveProject);
|
||||
router.delete('/delete/:id', verifyJWT, isMentorOrAdmin, projectController.archiveProject);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -332,7 +676,7 @@ router.get('/my-tasks', verifyJWT, projectController.getMyTasks);
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.get('/mentor-projects', verifyJWT, isAdmin, projectController.getMentorProjects);
|
||||
router.get('/mentor-projects', verifyJWT, isMentorOrAdmin, projectController.getMentorProjects);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -391,7 +735,7 @@ router.get('/mentor-projects', verifyJWT, isAdmin, projectController.getMentorPr
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.get('/interns', verifyJWT, isAdmin, projectController.getInterns);
|
||||
router.get('/interns', verifyJWT, isMentorOrAdmin, projectController.getInterns);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -434,6 +778,6 @@ router.get('/interns', verifyJWT, isAdmin, projectController.getInterns);
|
||||
* 500:
|
||||
* description: Internal server error
|
||||
*/
|
||||
router.post('/assign-member', verifyJWT, isAdmin, projectController.assignMember);
|
||||
router.post('/assign-member', verifyJWT, isMentorOrAdmin, projectController.assignMember);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user