Commit 8081474a authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 47720cbe
...@@ -45,7 +45,6 @@ export const createCurriculum = async (req, res) => { ...@@ -45,7 +45,6 @@ export const createCurriculum = async (req, res) => {
} }
} }
export const updateCurriculum = async (req, res) => { export const updateCurriculum = async (req, res) => {
const { id } = req.params; const { id } = req.params;
const updatedCurriculum = req.body; const updatedCurriculum = req.body;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
"nodemailer": "^6.9.1", "nodemailer": "^6.9.1",
"nodemon": "^2.0.22", "nodemon": "^2.0.22",
"react-mic": "^12.4.6", "react-mic": "^12.4.6",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
"torch": "^0.2.7", "torch": "^0.2.7",
"uuid": "^9.0.0" "uuid": "^9.0.0"
} }
......
...@@ -9,10 +9,127 @@ import { ...@@ -9,10 +9,127 @@ import {
const router = express.Router(); const router = express.Router();
/**
* @swagger
* /rest_node/curriculum:
* get:
* summary: Get all curriculums
* description: Retrieve a list of all curriculums along with their tutorials.
* tags:
* - Curriculum
* responses:
* 200:
* description: Successful response with curriculum data.
* 500:
* description: Internal server error.
*/
router.get('/', getAllCurriculums); router.get('/', getAllCurriculums);
/**
* @swagger
* /rest_node/curriculum/{id}:
* get:
* summary: Get a curriculum by ID
* description: Retrieve a curriculum by its ID along with its tutorials.
* tags:
* - Curriculum
* parameters:
* - in: path
* name: id
* description: Curriculum ID to fetch
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Successful response with curriculum data.
* 404:
* description: Curriculum not found.
* 500:
* description: Internal server error.
*/
router.get('/:id', getCurriculumById); router.get('/:id', getCurriculumById);
/**
* @swagger
* /rest_node/curriculum:
* post:
* summary: Create a new curriculum
* description: Create a new curriculum along with calculating its total tutorial mark.
* tags:
* - Curriculum
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/Curriculum'
* responses:
* 201:
* description: Curriculum created successfully.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.post('/', createCurriculum); router.post('/', createCurriculum);
/**
* @swagger
* /rest_node/curriculum/{id}:
* put:
* summary: Update a curriculum by ID
* description: Update a curriculum by its ID along with recalculating its total tutorial mark.
* tags:
* - Curriculum
* parameters:
* - in: path
* name: id
* description: Curriculum ID to update
* required: true
* schema:
* type: string
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/Curriculum'
* responses:
* 200:
* description: Curriculum updated successfully.
* 404:
* description: Curriculum not found.
* 500:
* description: Internal server error.
*/
router.put('/:id', updateCurriculum); router.put('/:id', updateCurriculum);
/**
* @swagger
* /rest_node/curriculum/{id}:
* delete:
* summary: Delete a curriculum by ID
* description: Delete a curriculum by its ID.
* tags:
* - Curriculum
* parameters:
* - in: path
* name: id
* description: Curriculum ID to delete
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Curriculum deleted successfully.
* 404:
* description: Curriculum not found.
* 500:
* description: Internal server error.
*/
router.delete('/:id', deleteCurriculum); router.delete('/:id', deleteCurriculum);
export default router; export default router;
...@@ -3,7 +3,54 @@ import { createFeedback, getFeedbackForEntity } from '../controllers/feedback.co ...@@ -3,7 +3,54 @@ import { createFeedback, getFeedbackForEntity } from '../controllers/feedback.co
const router = express.Router(); const router = express.Router();
/**
* @swagger
* /rest_node/feedback:
* post:
* summary: Create feedback for an entity
* description: Create feedback for a specific entity.
* tags:
* - Feedback
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/FeedbackInput'
* responses:
* 201:
* description: Feedback created successfully.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.post('/', createFeedback); router.post('/', createFeedback);
/**
* @swagger
* /rest_node/feedback/{entityId}:
* get:
* summary: Get feedback for an entity
* description: Retrieve feedback for a specific entity based on its ID.
* tags:
* - Feedback
* parameters:
* - in: path
* name: entityId
* description: Entity ID to fetch feedback for
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Successful response with feedback data.
* 404:
* description: Feedback not found for the specified entity.
* 500:
* description: Internal server error.
*/
router.get('/:entityId', getFeedbackForEntity); router.get('/:entityId', getFeedbackForEntity);
export default router; export default router;
...@@ -3,6 +3,20 @@ import { getGlobalLeaderboard } from '../controllers/leaderboard.controller.js'; ...@@ -3,6 +3,20 @@ import { getGlobalLeaderboard } from '../controllers/leaderboard.controller.js';
const router = express.Router(); const router = express.Router();
/**
* @swagger
* /rest_node/leaderboard/global:
* get:
* summary: Get global leaderboard
* description: Retrieve the global leaderboard data.
* tags:
* - Lead Board
* responses:
* 200:
* description: Successful response with global leaderboard data.
* 500:
* description: Internal server error.
*/
router.get('/global', getGlobalLeaderboard); router.get('/global', getGlobalLeaderboard);
export default router; export default router;
...@@ -8,6 +8,47 @@ const upload = multer({ storage: storage }); ...@@ -8,6 +8,47 @@ const upload = multer({ storage: storage });
const router = express.Router(); const router = express.Router();
router.post('/curriculum/:curriculumIndex/tutorial/:tutorialIndex', upload.single('image'), marksCalculator) /**
* @swagger
* /rest_node/marks-calculator/curriculum/{curriculumIndex}/tutorial/{tutorialIndex}:
* post:
* summary: Calculate marks for a tutorial
* description: Calculate marks for a tutorial within a curriculum.
* tags:
* - Score Calculator
* parameters:
* - in: path
* name: curriculumIndex
* description: Index of the curriculum
* required: true
* schema:
* type: integer
* - in: path
* name: tutorialIndex
* description: Index of the tutorial
* required: true
* schema:
* type: integer
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* image:
* type: string
* format: binary
* required:
* - image
* responses:
* 200:
* description: Marks calculated successfully.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.post('/curriculum/:curriculumIndex/tutorial/:tutorialIndex', upload.single('image'), marksCalculator);
export default router; export default router;
\ No newline at end of file
import express from "express"; import express from "express";
import { import {
createTutorial,
deleteTutorial,
getAllTutorials, getAllTutorials,
getTutorialById, getTutorialById,
createTutorial, updateTutorial
updateTutorial,
deleteTutorial
} from "../controllers/tutorial.controller.js"; } from "../controllers/tutorial.controller.js";
const router = express.Router(); const router = express.Router();
/**
* @swagger
* /rest_node/tutorial:
* get:
* summary: Get all tutorials
* description: Retrieve a list of all tutorials.
* tags:
* - Tutorial
* responses:
* 200:
* description: Successful response with tutorial data.
* 500:
* description: Internal server error.
*/
router.get('/', getAllTutorials); router.get('/', getAllTutorials);
/**
* @swagger
* /rest_node/tutorial/{id}:
* get:
* summary: Get a tutorial by ID
* description: Retrieve a tutorial by its ID.
* tags:
* - Tutorial
* parameters:
* - in: path
* name: id
* description: Tutorial ID to fetch
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Successful response with tutorial data.
* 404:
* description: Tutorial not found.
* 500:
* description: Internal server error.
*/
router.get('/:id', getTutorialById); router.get('/:id', getTutorialById);
/**
* @swagger
* /rest_node/tutorial:
* post:
* summary: Create a new tutorial
* description: Create a new tutorial.
* tags:
* - Tutorial
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/TutorialInput'
* responses:
* 201:
* description: Tutorial created successfully.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.post('/', createTutorial); router.post('/', createTutorial);
/**
* @swagger
* /rest_node/tutorial/{id}:
* put:
* summary: Update a tutorial by ID
* description: Update a tutorial by its ID.
* tags:
* - Tutorial
* parameters:
* - in: path
* name: id
* description: Tutorial ID to update
* required: true
* schema:
* type: string
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/TutorialInput'
* responses:
* 200:
* description: Tutorial updated successfully.
* 404:
* description: Tutorial not found.
* 500:
* description: Internal server error.
*/
router.put('/:id', updateTutorial); router.put('/:id', updateTutorial);
/**
* @swagger
* /rest_node/tutorial/{id}:
* delete:
* summary: Delete a tutorial by ID
* description: Delete a tutorial by its ID.
* tags:
* - Tutorial
* parameters:
* - in: path
* name: id
* description: Tutorial ID to delete
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Tutorial deleted successfully.
* 404:
* description: Tutorial not found.
* 500:
* description: Internal server error.
*/
router.delete('/:id', deleteTutorial); router.delete('/:id', deleteTutorial);
export default router; export default router;
...@@ -4,13 +4,195 @@ import auth from "../middleware/auth.middleware.js"; ...@@ -4,13 +4,195 @@ import auth from "../middleware/auth.middleware.js";
const router = express.Router(); const router = express.Router();
router.post('/sign-in', signIn) /**
router.post('/sign-up', signUp) * @swagger
* /rest_node/user/sign-in:
* post:
* summary: Sign in
* description: Sign in to the application.
* tags:
* - User
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/SignInInput'
* responses:
* 200:
* description: Sign in successful.
* 400:
* description: Bad request, check your input data.
* 401:
* description: Unauthorized, invalid credentials.
* 500:
* description: Internal server error.
*/
router.post('/sign-in', signIn);
/**
* @swagger
* /rest_node/user/sign-up:
* post:
* summary: Sign up
* description: Sign up for a new user account.
* tags:
* - User
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/SignUpInput'
* responses:
* 201:
* description: Sign up successful.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.post('/sign-up', signUp);
/**
* @swagger
* /rest_node/user/all:
* get:
* summary: Get all users
* description: Retrieve a list of all users.
* tags:
* - User
* responses:
* 200:
* description: Successful response with user data.
* 500:
* description: Internal server error.
*/
router.get('/all', getUsers); router.get('/all', getUsers);
/**
* @swagger
* /rest_node/user/current-user:
* get:
* summary: Get current user
* description: Retrieve information about the current authenticated user.
* tags:
* - User
* responses:
* 200:
* description: Successful response with current user data.
* 401:
* description: Unauthorized, authentication required.
* 500:
* description: Internal server error.
*/
router.get('/current-user', auth, currentUser); router.get('/current-user', auth, currentUser);
/**
* @swagger
* /rest_node/user/{id}:
* get:
* summary: Get user by ID
* description: Retrieve a user by their ID.
* tags:
* - User
* parameters:
* - in: path
* name: id
* description: User ID to fetch
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Successful response with user data.
* 404:
* description: User not found.
* 500:
* description: Internal server error.
*/
router.get('/:id', getUser); router.get('/:id', getUser);
/**
* @swagger
* /rest_node/user/all/type/{userType}:
* get:
* summary: Get users by user type
* description: Retrieve users based on their user type.
* tags:
* - User
* parameters:
* - in: path
* name: userType
* description: User type to filter users by
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Successful response with filtered user data.
* 500:
* description: Internal server error.
*/
router.get('/all/type/:userType', getUserAccordingToType); router.get('/all/type/:userType', getUserAccordingToType);
/**
* @swagger
* /rest_node/user/{id}:
* put:
* summary: Update user by ID
* description: Update a user by their ID.
* tags:
* - User
* parameters:
* - in: path
* name: id
* description: User ID to update
* required: true
* schema:
* type: string
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/UserUpdateInput'
* responses:
* 200:
* description: User updated successfully.
* 404:
* description: User not found.
* 500:
* description: Internal server error.
*/
router.put('/:id', updateUser); router.put('/:id', updateUser);
/**
* @swagger
* /rest_node/user/{id}:
* delete:
* summary: Delete user by ID
* description: Delete a user by their ID.
* tags:
* - User
* parameters:
* - in: path
* name: id
* description: User ID to delete
* required: true
* schema:
* type: string
* responses:
* 200:
* description: User deleted successfully.
* 404:
* description: User not found.
* 500:
* description: Internal server error.
*/
router.delete('/:id', deleteUser); router.delete('/:id', deleteUser);
export default router; export default router;
\ No newline at end of file
...@@ -3,8 +3,79 @@ import { getUserProgress, subscribeCurriculum, updateTaskItemProgress } from ".. ...@@ -3,8 +3,79 @@ import { getUserProgress, subscribeCurriculum, updateTaskItemProgress } from "..
const router = express.Router(); const router = express.Router();
/**
* @swagger
* /rest_node/user-progress/subscribe-curriculum:
* post:
* summary: Subscribe to a curriculum
* description: Subscribe a user to a curriculum to track their progress.
* tags:
* - User Progress
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/SubscribeCurriculumInput'
* responses:
* 200:
* description: User subscribed to the curriculum successfully.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.post('/subscribe-curriculum', subscribeCurriculum); router.post('/subscribe-curriculum', subscribeCurriculum);
/**
* @swagger
* /rest_node/user-progress/{userId}:
* get:
* summary: Get user progress
* description: Retrieve the progress of a user by their ID.
* tags:
* - User Progress
* parameters:
* - in: path
* name: userId
* description: User ID to fetch progress for
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Successful response with user progress data.
* 404:
* description: User not found or progress not available.
* 500:
* description: Internal server error.
*/
router.get('/:userId', getUserProgress); router.get('/:userId', getUserProgress);
/**
* @swagger
* /rest_node/user-progress/update-task-item-progress:
* put:
* summary: Update task item progress
* description: Update the progress of a task item for a user.
* tags:
* - User Progress
* requestBody:
* required: true
* content:
* application/json:
* schema:
* # You can define the schema separately.
* $ref: '#/components/schemas/UpdateTaskItemProgressInput'
* responses:
* 200:
* description: Task item progress updated successfully.
* 400:
* description: Bad request, check your input data.
* 500:
* description: Internal server error.
*/
router.put('/update-task-item-progress', updateTaskItemProgress); router.put('/update-task-item-progress', updateTaskItemProgress);
export default router; export default router;
...@@ -3,9 +3,35 @@ import cors from "cors"; ...@@ -3,9 +3,35 @@ import cors from "cors";
import dotenv from "dotenv"; import dotenv from "dotenv";
import express from "express"; import express from "express";
import mongoose from "mongoose"; import mongoose from "mongoose";
import multer from "multer"; import multer from "multer";
//swagger doc
import swaggerJsdoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
const swaggerOptions = {
swaggerDefinition: {
info: {
title: "Sign Connect Plus API Documentation",
version: "1.0.0",
description: "Documentation for Sign Connect Plus Node Backend API",
},
basePath: "/rest_node", // Specify the base path of your API
},
apis: [
"./routes/curriculum.routes.js",
"./routes/feedback.routes.js",
"./routes/leaderboard.routes.js",
"./routes/marksCalculator.routes.js",
"./routes/translate.routes.js",
"./routes/tutorial.routes.js",
"./routes/user.routes.js",
"./routes/userProgress.routes.js",
],
};
const swaggerSpec = swaggerJsdoc(swaggerOptions);
// Set up storage for uploaded images // Set up storage for uploaded images
const storage = multer.memoryStorage(); const storage = multer.memoryStorage();
const upload = multer({ storage: storage }); const upload = multer({ storage: storage });
...@@ -47,6 +73,8 @@ app.use("/rest_node/feedback", feedbackRoutes); ...@@ -47,6 +73,8 @@ app.use("/rest_node/feedback", feedbackRoutes);
app.use("/rest_node/leaderboard", leaderboardRoutes); app.use("/rest_node/leaderboard", leaderboardRoutes);
app.use("/rest_node/marks-calculator", marksCalculatorRoutes); app.use("/rest_node/marks-calculator", marksCalculatorRoutes);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
const CONNECTION_URL = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@researchmanagement-appl.vzhn4.mongodb.net/?retryWrites=true&w=majority`; const CONNECTION_URL = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@researchmanagement-appl.vzhn4.mongodb.net/?retryWrites=true&w=majority`;
const PORT = process.env.PORT || 5000; const PORT = process.env.PORT || 5000;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment