aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/storyboard.ts
blob: 47a22011d391d5ccadf057108c9573262ace9e1f (plain) (blame)
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
import express from 'express'
import { getVideoWithAttributes } from '@server/helpers/video'
import { StoryboardModel } from '@server/models/video/storyboard'
import { asyncMiddleware, videosGetValidator } from '../../../middlewares'

const storyboardRouter = express.Router()

storyboardRouter.get('/:id/storyboards',
  asyncMiddleware(videosGetValidator),
  asyncMiddleware(listStoryboards)
)

// ---------------------------------------------------------------------------

export {
  storyboardRouter
}

// ---------------------------------------------------------------------------

async function listStoryboards (req: express.Request, res: express.Response) {
  const video = getVideoWithAttributes(res)

  const storyboards = await StoryboardModel.listStoryboardsOf(video)

  return res.json({
    storyboards: storyboards.map(s => s.toFormattedJSON())
  })
}