All files / routes/api attachment.js

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

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 1915x 15x 15x   15x 15x 15x   15x   15x   15x 15x 15x   15x    
const { Router } = require('express')
const router = Router()
const multer = require('multer')
 
module.exports = (crowi, app, 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
}