# All files / Backend/routes teacher.js

59.38% Statements 19/32
0% Branches 0/7
0% Functions 0/6
59.38% Lines 19/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    584x
    4x
    4x
    4x
    4x

    4x

    4x

    4x

    4x

    4x
    4x

    4x
    4x
    4x
    4x
    4x
    4x
    4x

    4x
     const express = require('express');
    const router= express.Router();
    const multer = require('multer');
    const teacherController =require('../controllers/teacher');
    const Auth = require('../Authentication/is-auth');

    const ImagefileStorage = multer.diskStorage({
        destination:(req,file,cb)=>{
          cb(null,'images');
        },
        filename: (req,file,cb)=>{
          cb(null, new Date().toDateString() + '-' + file.originalname)
        }
      })

      const ImagefileFilter=(req,file,cb)=>{
        if(file.mimetype ==="image/png" || file.mimetype==="image/jpg" || file.mimetype==="image/jpeg"){
          cb(null,true);
        }
        else {cb(null,false);
              console.log("wrong file type")}
      }

      const VideofileStorage = multer.diskStorage({
        destination:(req,file,cb)=>{
          cb(null,'videos');
        },
        filename: (req,file,cb)=>{
          const currentDate= new Date();
          cb(null, currentDate.toDateString() +'-' + file.originalname)
        }
      })

      const VideofileFilter=(req,file,cb)=>{
        if(file.mimetype ==="video/mp4"){
          cb(null,true);
        }
        else {cb(null,false);
              console.log("wrong file type")}
      }

    const imageMulter=multer({storage:ImagefileStorage,fileFilter:ImagefileFilter}).single('image')
    const videoMulter=multer({storage:VideofileStorage,fileFilter:VideofileFilter}).any()

    router.post('/creator/create-course',imageMulter,teacherController.uploadCourse);
    router.post('/creator/videoUpload/:courseID',videoMulter,teacherController.uploadVideo);
    router.post('/creater/homepage',Auth.authentication,teacherController.teacherHome);
    router.post('/course/delete',Auth.authentication,teacherController.deleteCourse);
    router.post('/course/edit',Auth.authentication,teacherController.editCourse);
    router.put('/course/Update',imageMulter,teacherController.updateCourse)
    router.post('/watchedByuser',teacherController.watchedByUsers)

    module.exports = router;