aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/initializers
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip
Type functions
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker.ts8
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/database.ts4
-rw-r--r--server/initializers/installer.ts8
-rw-r--r--server/initializers/migrator.ts9
5 files changed, 16 insertions, 15 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 8c3d64b60..7007f2c0b 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -23,7 +23,7 @@ function checkMissedConfig () {
23 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', 23 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews',
24 'admin.email', 'signup.enabled', 'transcoding.enabled', 'transcoding.threads' 24 'admin.email', 'signup.enabled', 'transcoding.enabled', 'transcoding.threads'
25 ] 25 ]
26 const miss = [] 26 const miss: string[] = []
27 27
28 for (const key of required) { 28 for (const key of required) {
29 if (!config.has(key)) { 29 if (!config.has(key)) {
@@ -35,7 +35,7 @@ function checkMissedConfig () {
35} 35}
36 36
37// Check the available codecs 37// Check the available codecs
38function checkFFmpeg (callback) { 38function checkFFmpeg (callback: (err: Error) => void) {
39 const Ffmpeg = require('fluent-ffmpeg') 39 const Ffmpeg = require('fluent-ffmpeg')
40 40
41 Ffmpeg.getAvailableCodecs(function (err, codecs) { 41 Ffmpeg.getAvailableCodecs(function (err, codecs) {
@@ -57,7 +57,7 @@ function checkFFmpeg (callback) {
57 }) 57 })
58} 58}
59 59
60function clientsExist (callback) { 60function clientsExist (callback: (err: Error, clientsExist?: boolean) => void) {
61 db.OAuthClient.countTotal(function (err, totalClients) { 61 db.OAuthClient.countTotal(function (err, totalClients) {
62 if (err) return callback(err) 62 if (err) return callback(err)
63 63
@@ -65,7 +65,7 @@ function clientsExist (callback) {
65 }) 65 })
66} 66}
67 67
68function usersExist (callback) { 68function usersExist (callback: (err: Error, usersExist?: boolean) => void) {
69 db.User.countTotal(function (err, totalUsers) { 69 db.User.countTotal(function (err, totalUsers) {
70 if (err) return callback(err) 70 if (err) return callback(err)
71 71
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 7ab019f44..6dcb4bb91 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -202,7 +202,7 @@ const REQUEST_ENDPOINTS = {
202 VIDEOS: 'videos' 202 VIDEOS: 'videos'
203} 203}
204 204
205const REQUEST_ENDPOINT_ACTIONS = {} 205const REQUEST_ENDPOINT_ACTIONS: { [ id: string ]: any } = {}
206REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = { 206REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] = {
207 ADD: 'add', 207 ADD: 'add',
208 UPDATE: 'update', 208 UPDATE: 'update',
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index b0f47876e..78ca5ab84 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -59,7 +59,7 @@ const sequelize = new Sequelize(dbname, username, password, {
59 port: CONFIG.DATABASE.PORT, 59 port: CONFIG.DATABASE.PORT,
60 benchmark: isTestInstance(), 60 benchmark: isTestInstance(),
61 61
62 logging: function (message, benchmark) { 62 logging: function (message: string, benchmark: number) {
63 let newMessage = message 63 let newMessage = message
64 if (benchmark !== undefined) { 64 if (benchmark !== undefined) {
65 newMessage += ' | ' + benchmark + 'ms' 65 newMessage += ' | ' + benchmark + 'ms'
@@ -71,7 +71,7 @@ const sequelize = new Sequelize(dbname, username, password, {
71 71
72database.sequelize = sequelize 72database.sequelize = sequelize
73 73
74database.init = function (silent, callback) { 74database.init = function (silent: boolean, callback: (err: Error) => void) {
75 75
76 const modelDirectory = join(__dirname, '..', 'models') 76 const modelDirectory = join(__dirname, '..', 'models')
77 fs.readdir(modelDirectory, function (err, files) { 77 fs.readdir(modelDirectory, function (err, files) {
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 2f9b58991..f105c8292 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -9,7 +9,7 @@ import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION } from './constants'
9import { clientsExist, usersExist } from './checker' 9import { clientsExist, usersExist } from './checker'
10import { logger, createCertsIfNotExist, root } from '../helpers' 10import { logger, createCertsIfNotExist, root } from '../helpers'
11 11
12function installApplication (callback) { 12function installApplication (callback: (err: Error) => void) {
13 series([ 13 series([
14 function createDatabase (callbackAsync) { 14 function createDatabase (callbackAsync) {
15 db.sequelize.sync().asCallback(callbackAsync) 15 db.sequelize.sync().asCallback(callbackAsync)
@@ -42,7 +42,7 @@ export {
42 42
43// --------------------------------------------------------------------------- 43// ---------------------------------------------------------------------------
44 44
45function createDirectoriesIfNotExist (callback) { 45function createDirectoriesIfNotExist (callback: (err: Error) => void) {
46 const storages = config.get('storage') 46 const storages = config.get('storage')
47 47
48 each(Object.keys(storages), function (key, callbackEach) { 48 each(Object.keys(storages), function (key, callbackEach) {
@@ -51,7 +51,7 @@ function createDirectoriesIfNotExist (callback) {
51 }, callback) 51 }, callback)
52} 52}
53 53
54function createOAuthClientIfNotExist (callback) { 54function createOAuthClientIfNotExist (callback: (err: Error) => void) {
55 clientsExist(function (err, exist) { 55 clientsExist(function (err, exist) {
56 if (err) return callback(err) 56 if (err) return callback(err)
57 57
@@ -80,7 +80,7 @@ function createOAuthClientIfNotExist (callback) {
80 }) 80 })
81} 81}
82 82
83function createOAuthAdminIfNotExist (callback) { 83function createOAuthAdminIfNotExist (callback: (err: Error) => void) {
84 usersExist(function (err, exist) { 84 usersExist(function (err, exist) {
85 if (err) return callback(err) 85 if (err) return callback(err)
86 86
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts
index 379d43af5..d72c60638 100644
--- a/server/initializers/migrator.ts
+++ b/server/initializers/migrator.ts
@@ -8,7 +8,7 @@ import { LAST_MIGRATION_VERSION } from './constants'
8import { logger } from '../helpers' 8import { logger } from '../helpers'
9import { ApplicationInstance } from '../models' 9import { ApplicationInstance } from '../models'
10 10
11function migrate (finalCallback) { 11function migrate (finalCallback: (err: Error) => void) {
12 waterfall([ 12 waterfall([
13 13
14 function checkApplicationTableExists (callback) { 14 function checkApplicationTableExists (callback) {
@@ -56,7 +56,7 @@ function migrate (finalCallback) {
56 }, 56 },
57 57
58 function doMigrations (actualVersion, migrationScripts, callback) { 58 function doMigrations (actualVersion, migrationScripts, callback) {
59 eachSeries(migrationScripts, function (entity, callbackEach) { 59 eachSeries(migrationScripts, function (entity: any, callbackEach) {
60 executeMigration(actualVersion, entity, callbackEach) 60 executeMigration(actualVersion, entity, callbackEach)
61 }, function (err) { 61 }, function (err) {
62 if (err) return callback(err) 62 if (err) return callback(err)
@@ -76,7 +76,8 @@ export {
76 76
77// --------------------------------------------------------------------------- 77// ---------------------------------------------------------------------------
78 78
79function getMigrationScripts (callback) { 79type GetMigrationScriptsCallback = (err: Error, filesToMigrate?: { version: string, script: string }[]) => void
80function getMigrationScripts (callback: GetMigrationScriptsCallback) {
80 fs.readdir(path.join(__dirname, 'migrations'), function (err, files) { 81 fs.readdir(path.join(__dirname, 'migrations'), function (err, files) {
81 if (err) return callback(err) 82 if (err) return callback(err)
82 83
@@ -95,7 +96,7 @@ function getMigrationScripts (callback) {
95 }) 96 })
96} 97}
97 98
98function executeMigration (actualVersion, entity, callback) { 99function executeMigration (actualVersion: number, entity: { version: string, script: string }, callback: (err: Error) => void) {
99 const versionScript = parseInt(entity.version, 10) 100 const versionScript = parseInt(entity.version, 10)
100 101
101 // Do not execute old migration scripts 102 // Do not execute old migration scripts