aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
commit154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch)
tree5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /server/controllers
parentdf98563e2104b82b119c00a3cd83cd0dc1242d25 (diff)
downloadPeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.gz
PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.zst
PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.zip
Share models between server and client
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/clients.ts6
-rw-r--r--server/controllers/api/config.ts6
-rw-r--r--server/controllers/api/users.ts6
3 files changed, 12 insertions, 6 deletions
diff --git a/server/controllers/api/clients.ts b/server/controllers/api/clients.ts
index 8c460096b..96490d04a 100644
--- a/server/controllers/api/clients.ts
+++ b/server/controllers/api/clients.ts
@@ -3,6 +3,7 @@ import * as express from 'express'
3import { CONFIG } from '../../initializers' 3import { CONFIG } from '../../initializers'
4import { logger } from '../../helpers' 4import { logger } from '../../helpers'
5import { database as db } from '../../initializers/database' 5import { database as db } from '../../initializers/database'
6import { ClientLocal } from '../../../shared'
6 7
7const clientsRouter = express.Router() 8const clientsRouter = express.Router()
8 9
@@ -27,10 +28,11 @@ function getLocalClient (req: express.Request, res: express.Response, next: expr
27 if (err) return next(err) 28 if (err) return next(err)
28 if (!client) return next(new Error('No client available.')) 29 if (!client) return next(new Error('No client available.'))
29 30
30 res.json({ 31 const json: ClientLocal = {
31 client_id: client.clientId, 32 client_id: client.clientId,
32 client_secret: client.clientSecret 33 client_secret: client.clientSecret
33 }) 34 }
35 res.json(json)
34 }) 36 })
35} 37}
36 38
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index c63981797..3e9aa77a5 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -1,6 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2 2
3import { CONFIG } from '../../initializers' 3import { CONFIG } from '../../initializers'
4import { ServerConfig } from '../../../shared'
4 5
5const configRouter = express.Router() 6const configRouter = express.Router()
6 7
@@ -8,11 +9,12 @@ configRouter.get('/', getConfig)
8 9
9// Get the client credentials for the PeerTube front end 10// Get the client credentials for the PeerTube front end
10function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { 11function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
11 res.json({ 12 const json: ServerConfig = {
12 signup: { 13 signup: {
13 enabled: CONFIG.SIGNUP.ENABLED 14 enabled: CONFIG.SIGNUP.ENABLED
14 } 15 }
15 }) 16 }
17 res.json(json)
16} 18}
17 19
18// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index ffe5881e5..1e9e65689 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -17,6 +17,7 @@ import {
17 setUsersSort, 17 setUsersSort,
18 token 18 token
19} from '../../middlewares' 19} from '../../middlewares'
20import { UserVideoRate as FormatedUserVideoRate } from '../../../shared'
20 21
21const usersRouter = express.Router() 22const usersRouter = express.Router()
22 23
@@ -119,10 +120,11 @@ function getUserVideoRating (req: express.Request, res: express.Response, next:
119 120
120 const rating = ratingObj ? ratingObj.type : 'none' 121 const rating = ratingObj ? ratingObj.type : 'none'
121 122
122 res.json({ 123 const json: FormatedUserVideoRate = {
123 videoId, 124 videoId,
124 rating 125 rating
125 }) 126 }
127 res.json(json)
126 }) 128 })
127} 129}
128 130