All files / lib/routes/api attachment.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 9/9

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      16x     16x 16x   16x   16x   16x 16x 16x   16x    
import { Router, Express } from 'express'
import Crowi from 'server/crowi'
import multer from 'multer'
const router = Router()
 
export default (crowi: Crowi, app: Express, form) => {
  const { Attachment } = crowi.controllers
  const { AccessTokenParser, LoginRequired, CsrfVerify: csrf } = crowi.middlewares
 
  const uploads = multer({ dest: crowi.tmpDir + 'uploads' })
 
  router.use('/attachments*', AccessTokenParser, LoginRequired)
 
  router.get('/attachments.list', Attachment.api.list)
  router.post('/attachments.add', uploads.single('file'), csrf, Attachment.api.add)
  router.post('/attachments.remove', csrf, Attachment.api.remove)
 
  return router
}