aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-07-25 22:01:25 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-07-25 22:01:25 +0200
commitc1e791bad0b079af67398f6407221e6dcbb573dd (patch)
tree82e5944b4458dd35aa482a38f6b650eb93bb89ad /server/initializers
parent5f7021c33d31c5255b995ae0ff86b5bbea4ea4b9 (diff)
downloadPeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.gz
PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.zst
PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.zip
expliciting type checks and predicates (server only)
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/installer.ts2
-rw-r--r--server/initializers/migrations/0005-email-pod.ts3
-rw-r--r--server/initializers/migrations/0010-email-user.ts3
-rw-r--r--server/initializers/migrations/0030-video-category.ts3
-rw-r--r--server/initializers/migrations/0035-video-licence.ts3
-rw-r--r--server/initializers/migrations/0040-video-nsfw.ts3
-rw-r--r--server/initializers/migrations/0055-video-uuid.ts2
-rw-r--r--server/initializers/migrations/0070-user-video-quota.ts3
-rw-r--r--server/initializers/migrations/0155-video-comments-enabled.ts3
-rw-r--r--server/initializers/migrations/0230-kue-to-bull.ts9
-rw-r--r--server/initializers/migrator.ts2
11 files changed, 20 insertions, 16 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 1f513a9c3..1926c40dd 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -52,7 +52,7 @@ function createDirectoriesIfNotExist () {
52 const cacheDirectories = Object.keys(CACHE) 52 const cacheDirectories = Object.keys(CACHE)
53 .map(k => CACHE[k].DIRECTORY) 53 .map(k => CACHE[k].DIRECTORY)
54 54
55 const tasks = [] 55 const tasks: Promise<string>[] = []
56 for (const key of Object.keys(storage)) { 56 for (const key of Object.keys(storage)) {
57 const dir = storage[key] 57 const dir = storage[key]
58 tasks.push(mkdirpPromise(dir)) 58 tasks.push(mkdirpPromise(dir))
diff --git a/server/initializers/migrations/0005-email-pod.ts b/server/initializers/migrations/0005-email-pod.ts
index ab60f3adb..c34a12255 100644
--- a/server/initializers/migrations/0005-email-pod.ts
+++ b/server/initializers/migrations/0005-email-pod.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { Migration } from '../../models/migrations'
3 4
4function up (utils: { 5function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -12,7 +13,7 @@ function up (utils: {
12 type: Sequelize.STRING(400), 13 type: Sequelize.STRING(400),
13 allowNull: false, 14 allowNull: false,
14 defaultValue: '' 15 defaultValue: ''
15 } 16 } as Migration.String
16 17
17 return q.addColumn('Pods', 'email', data) 18 return q.addColumn('Pods', 'email', data)
18 .then(() => { 19 .then(() => {
diff --git a/server/initializers/migrations/0010-email-user.ts b/server/initializers/migrations/0010-email-user.ts
index 33d13ce55..37a7b0bb3 100644
--- a/server/initializers/migrations/0010-email-user.ts
+++ b/server/initializers/migrations/0010-email-user.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { Migration } from '../../models/migrations'
3 4
4function up (utils: { 5function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -12,7 +13,7 @@ function up (utils: {
12 type: Sequelize.STRING(400), 13 type: Sequelize.STRING(400),
13 allowNull: false, 14 allowNull: false,
14 defaultValue: '' 15 defaultValue: ''
15 } 16 } as Migration.String
16 return q.addColumn('Users', 'email', data) 17 return q.addColumn('Users', 'email', data)
17 .then(() => { 18 .then(() => {
18 const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')' 19 const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')'
diff --git a/server/initializers/migrations/0030-video-category.ts b/server/initializers/migrations/0030-video-category.ts
index 41bc1aa98..f784f820d 100644
--- a/server/initializers/migrations/0030-video-category.ts
+++ b/server/initializers/migrations/0030-video-category.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { Migration } from '../../models/migrations'
3 4
4function up (utils: { 5function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -12,7 +13,7 @@ function up (utils: {
12 type: Sequelize.INTEGER, 13 type: Sequelize.INTEGER,
13 allowNull: false, 14 allowNull: false,
14 defaultValue: 0 15 defaultValue: 0
15 } 16 } as Migration.Integer
16 17
17 return q.addColumn('Videos', 'category', data) 18 return q.addColumn('Videos', 'category', data)
18 .then(() => { 19 .then(() => {
diff --git a/server/initializers/migrations/0035-video-licence.ts b/server/initializers/migrations/0035-video-licence.ts
index 7ab49e147..3d0b0bac9 100644
--- a/server/initializers/migrations/0035-video-licence.ts
+++ b/server/initializers/migrations/0035-video-licence.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { Migration } from '../../models/migrations'
3 4
4function up (utils: { 5function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -12,7 +13,7 @@ function up (utils: {
12 type: Sequelize.INTEGER, 13 type: Sequelize.INTEGER,
13 allowNull: false, 14 allowNull: false,
14 defaultValue: 0 15 defaultValue: 0
15 } 16 } as Migration.Integer
16 17
17 return q.addColumn('Videos', 'licence', data) 18 return q.addColumn('Videos', 'licence', data)
18 .then(() => { 19 .then(() => {
diff --git a/server/initializers/migrations/0040-video-nsfw.ts b/server/initializers/migrations/0040-video-nsfw.ts
index 0460e661d..f7f70d3c4 100644
--- a/server/initializers/migrations/0040-video-nsfw.ts
+++ b/server/initializers/migrations/0040-video-nsfw.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { Migration } from '../../models/migrations'
3 4
4function up (utils: { 5function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -12,7 +13,7 @@ function up (utils: {
12 type: Sequelize.BOOLEAN, 13 type: Sequelize.BOOLEAN,
13 allowNull: false, 14 allowNull: false,
14 defaultValue: false 15 defaultValue: false
15 } 16 } as Migration.Boolean
16 17
17 return q.addColumn('Videos', 'nsfw', data) 18 return q.addColumn('Videos', 'nsfw', data)
18 .then(() => { 19 .then(() => {
diff --git a/server/initializers/migrations/0055-video-uuid.ts b/server/initializers/migrations/0055-video-uuid.ts
index 9bc65917c..6db25f193 100644
--- a/server/initializers/migrations/0055-video-uuid.ts
+++ b/server/initializers/migrations/0055-video-uuid.ts
@@ -24,7 +24,7 @@ function up (utils: {
24 return utils.sequelize.query(query) 24 return utils.sequelize.query(query)
25 }) 25 })
26 .then(() => { 26 .then(() => {
27 dataUUID.defaultValue = null 27 dataUUID.defaultValue = null // FIXME:default value cannot be null if string
28 28
29 return q.changeColumn('Videos', 'uuid', dataUUID) 29 return q.changeColumn('Videos', 'uuid', dataUUID)
30 }) 30 })
diff --git a/server/initializers/migrations/0070-user-video-quota.ts b/server/initializers/migrations/0070-user-video-quota.ts
index dec4d46dd..37683432f 100644
--- a/server/initializers/migrations/0070-user-video-quota.ts
+++ b/server/initializers/migrations/0070-user-video-quota.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { Migration } from '../../models/migrations'
3 4
4function up (utils: { 5function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -13,7 +14,7 @@ function up (utils: {
13 type: Sequelize.BIGINT, 14 type: Sequelize.BIGINT,
14 allowNull: false, 15 allowNull: false,
15 defaultValue: -1 16 defaultValue: -1
16 } 17 } as Migration.BigInteger
17 18
18 return q.addColumn('Users', 'videoQuota', data) 19 return q.addColumn('Users', 'videoQuota', data)
19 .then(() => { 20 .then(() => {
diff --git a/server/initializers/migrations/0155-video-comments-enabled.ts b/server/initializers/migrations/0155-video-comments-enabled.ts
index 59f4110de..6949d3a0c 100644
--- a/server/initializers/migrations/0155-video-comments-enabled.ts
+++ b/server/initializers/migrations/0155-video-comments-enabled.ts
@@ -1,4 +1,5 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { Migration } from '../../models/migrations'
2 3
3async function up (utils: { 4async function up (utils: {
4 transaction: Sequelize.Transaction, 5 transaction: Sequelize.Transaction,
@@ -9,7 +10,7 @@ async function up (utils: {
9 type: Sequelize.BOOLEAN, 10 type: Sequelize.BOOLEAN,
10 allowNull: false, 11 allowNull: false,
11 defaultValue: true 12 defaultValue: true
12 } 13 } as Migration.Boolean
13 await utils.queryInterface.addColumn('video', 'commentsEnabled', data) 14 await utils.queryInterface.addColumn('video', 'commentsEnabled', data)
14 15
15 data.defaultValue = null 16 data.defaultValue = null
diff --git a/server/initializers/migrations/0230-kue-to-bull.ts b/server/initializers/migrations/0230-kue-to-bull.ts
index 5fad87a61..5f4d88bef 100644
--- a/server/initializers/migrations/0230-kue-to-bull.ts
+++ b/server/initializers/migrations/0230-kue-to-bull.ts
@@ -2,6 +2,7 @@ import * as Sequelize from 'sequelize'
2import { createClient } from 'redis' 2import { createClient } from 'redis'
3import { CONFIG } from '../constants' 3import { CONFIG } from '../constants'
4import { JobQueue } from '../../lib/job-queue' 4import { JobQueue } from '../../lib/job-queue'
5import { Redis } from '../../lib/redis'
5import { initDatabaseModels } from '../database' 6import { initDatabaseModels } from '../database'
6 7
7async function up (utils: { 8async function up (utils: {
@@ -12,11 +13,7 @@ async function up (utils: {
12 await initDatabaseModels(false) 13 await initDatabaseModels(false)
13 14
14 return new Promise((res, rej) => { 15 return new Promise((res, rej) => {
15 const client = createClient({ 16 const client = createClient(Redis.getRedisClient())
16 host: CONFIG.REDIS.HOSTNAME,
17 port: CONFIG.REDIS.PORT,
18 db: CONFIG.REDIS.DB
19 })
20 17
21 const jobsPrefix = 'q-' + CONFIG.WEBSERVER.HOST 18 const jobsPrefix = 'q-' + CONFIG.WEBSERVER.HOST
22 19
@@ -36,7 +33,7 @@ async function up (utils: {
36 return res({ type: job.type, payload: parsedData }) 33 return res({ type: job.type, payload: parsedData })
37 } catch (err) { 34 } catch (err) {
38 console.error('Cannot parse data %s.', job.data) 35 console.error('Cannot parse data %s.', job.data)
39 return res(null) 36 return res(undefined)
40 } 37 }
41 }) 38 })
42 }) 39 })
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts
index 466369729..539e2bc8f 100644
--- a/server/initializers/migrator.ts
+++ b/server/initializers/migrator.ts
@@ -11,7 +11,7 @@ async function migrate () {
11 // The installer will do that 11 // The installer will do that
12 if (tables.length === 0) return 12 if (tables.length === 0) return
13 13
14 let actualVersion: number = null 14 let actualVersion: number | null = null
15 15
16 const [ rows ] = await sequelizeTypescript.query('SELECT "migrationVersion" FROM "application"') 16 const [ rows ] = await sequelizeTypescript.query('SELECT "migrationVersion" FROM "application"')
17 if (rows && rows[0] && rows[0].migrationVersion) { 17 if (rows && rows[0] && rows[0].migrationVersion) {