aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r--server/controllers/client.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index c3d28245c..503eff750 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -12,6 +12,7 @@ import {
12 STATIC_MAX_AGE 12 STATIC_MAX_AGE
13} from '../initializers' 13} from '../initializers'
14import { root } from '../helpers' 14import { root } from '../helpers'
15import { VideoInstance } from '../models'
15 16
16const clientsRouter = express.Router() 17const clientsRouter = express.Router()
17 18
@@ -25,7 +26,7 @@ const indexPath = join(distPath, 'index.html')
25// Do not use a template engine for a so little thing 26// Do not use a template engine for a so little thing
26clientsRouter.use('/videos/watch/:id', generateWatchHtmlPage) 27clientsRouter.use('/videos/watch/:id', generateWatchHtmlPage)
27 28
28clientsRouter.use('/videos/embed', function (req, res, next) { 29clientsRouter.use('/videos/embed', function (req: express.Request, res: express.Response, next: express.NextFunction) {
29 res.sendFile(embedPath) 30 res.sendFile(embedPath)
30}) 31})
31 32
@@ -33,7 +34,7 @@ clientsRouter.use('/videos/embed', function (req, res, next) {
33clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE })) 34clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE }))
34 35
35// 404 for static files not found 36// 404 for static files not found
36clientsRouter.use('/client/*', function (req, res, next) { 37clientsRouter.use('/client/*', function (req: express.Request, res: express.Response, next: express.NextFunction) {
37 res.sendStatus(404) 38 res.sendStatus(404)
38}) 39})
39 40
@@ -45,7 +46,7 @@ export {
45 46
46// --------------------------------------------------------------------------- 47// ---------------------------------------------------------------------------
47 48
48function addOpenGraphTags (htmlStringPage, video) { 49function addOpenGraphTags (htmlStringPage: string, video: VideoInstance) {
49 let basePreviewUrlHttp 50 let basePreviewUrlHttp
50 51
51 if (video.isOwned()) { 52 if (video.isOwned()) {
@@ -88,8 +89,8 @@ function addOpenGraphTags (htmlStringPage, video) {
88 return htmlStringPage.replace(opengraphComment, tagsString) 89 return htmlStringPage.replace(opengraphComment, tagsString)
89} 90}
90 91
91function generateWatchHtmlPage (req, res, next) { 92function generateWatchHtmlPage (req: express.Request, res: express.Response, next: express.NextFunction) {
92 const videoId = req.params.id 93 const videoId = '' + req.params.id
93 94
94 // Let Angular application handle errors 95 // Let Angular application handle errors
95 if (!validator.isUUID(videoId, 4)) return res.sendFile(indexPath) 96 if (!validator.isUUID(videoId, 4)) return res.sendFile(indexPath)
@@ -102,7 +103,7 @@ function generateWatchHtmlPage (req, res, next) {
102 video: function (callback) { 103 video: function (callback) {
103 db.Video.loadAndPopulateAuthorAndPodAndTags(videoId, callback) 104 db.Video.loadAndPopulateAuthorAndPodAndTags(videoId, callback)
104 } 105 }
105 }, function (err, result: any) { 106 }, function (err: Error, result: { file: Buffer, video: VideoInstance }) {
106 if (err) return next(err) 107 if (err) return next(err)
107 108
108 const html = result.file.toString() 109 const html = result.file.toString()