1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Move models to typescript-sequelize

This commit is contained in:
Chocobozzz 2017-12-12 17:53:50 +01:00
parent c893d4514e
commit 3fd3ab2d34
No known key found for this signature in database
GPG key ID: 583A612D890159BE
150 changed files with 3676 additions and 5074 deletions

View file

@ -2,8 +2,6 @@ import * as express from 'express'
import { join } from 'path'
import * as validator from 'validator'
import * as Bluebird from 'bluebird'
import { database as db } from '../initializers/database'
import {
CONFIG,
STATIC_PATHS,
@ -13,7 +11,7 @@ import {
} from '../initializers'
import { root, readFileBufferPromise, escapeHTML } from '../helpers'
import { asyncMiddleware } from '../middlewares'
import { VideoInstance } from '../models'
import { VideoModel } from '../models/video/video'
const clientsRouter = express.Router()
@ -49,7 +47,7 @@ export {
// ---------------------------------------------------------------------------
function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoInstance) {
function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
const previewUrl = CONFIG.WEBSERVER.URL + STATIC_PATHS.PREVIEWS + video.getPreviewName()
const videoUrl = CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
@ -108,13 +106,13 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoInstance
async function generateWatchHtmlPage (req: express.Request, res: express.Response, next: express.NextFunction) {
const videoId = '' + req.params.id
let videoPromise: Bluebird<VideoInstance>
let videoPromise: Bluebird<VideoModel>
// Let Angular application handle errors
if (validator.isUUID(videoId, 4)) {
videoPromise = db.Video.loadByUUIDAndPopulateAccountAndServerAndTags(videoId)
videoPromise = VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(videoId)
} else if (validator.isInt(videoId)) {
videoPromise = db.Video.loadAndPopulateAccountAndServerAndTags(+videoId)
videoPromise = VideoModel.loadAndPopulateAccountAndServerAndTags(+videoId)
} else {
return res.sendFile(indexPath)
}