aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/oauth-clients.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /server/controllers/api/oauth-clients.ts
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server/controllers/api/oauth-clients.ts')
-rw-r--r--server/controllers/api/oauth-clients.ts21
1 files changed, 11 insertions, 10 deletions
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index b9bc0534f..f7dac598c 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -24,16 +24,17 @@ function getLocalClient (req: express.Request, res: express.Response, next: expr
24 return res.type('json').status(403).end() 24 return res.type('json').status(403).end()
25 } 25 }
26 26
27 db.OAuthClient.loadFirstClient(function (err, client) { 27 db.OAuthClient.loadFirstClient()
28 if (err) return next(err) 28 .then(client => {
29 if (!client) return next(new Error('No client available.')) 29 if (!client) throw new Error('No client available.')
30 30
31 const json: OAuthClientLocal = { 31 const json: OAuthClientLocal = {
32 client_id: client.clientId, 32 client_id: client.clientId,
33 client_secret: client.clientSecret 33 client_secret: client.clientSecret
34 } 34 }
35 res.json(json) 35 res.json(json)
36 }) 36 })
37 .catch(err => next(err))
37} 38}
38 39
39// --------------------------------------------------------------------------- 40// ---------------------------------------------------------------------------