mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
This commit is contained in:
parent
5fe7e89831
commit
6fcd19ba73
88 changed files with 1980 additions and 2505 deletions
|
@ -1,13 +1,12 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import * as Promise from 'bluebird'
|
||||
|
||||
export namespace OAuthClientMethods {
|
||||
export type CountTotalCallback = (err: Error, total: number) => void
|
||||
export type CountTotal = (callback: CountTotalCallback) => void
|
||||
export type CountTotal = () => Promise<number>
|
||||
|
||||
export type LoadFirstClientCallback = (err: Error, client: OAuthClientInstance) => void
|
||||
export type LoadFirstClient = (callback: LoadFirstClientCallback) => void
|
||||
export type LoadFirstClient = () => Promise<OAuthClientInstance>
|
||||
|
||||
export type GetByIdAndSecret = (clientId, clientSecret) => void
|
||||
export type GetByIdAndSecret = (clientId: string, clientSecret: string) => Promise<OAuthClientInstance>
|
||||
}
|
||||
|
||||
export interface OAuthClientClass {
|
||||
|
|
|
@ -2,7 +2,6 @@ import * as Sequelize from 'sequelize'
|
|||
|
||||
import { addMethodsToModel } from '../utils'
|
||||
import {
|
||||
OAuthClientClass,
|
||||
OAuthClientInstance,
|
||||
OAuthClientAttributes,
|
||||
|
||||
|
@ -67,12 +66,12 @@ function associate (models) {
|
|||
})
|
||||
}
|
||||
|
||||
countTotal = function (callback: OAuthClientMethods.CountTotalCallback) {
|
||||
return OAuthClient.count().asCallback(callback)
|
||||
countTotal = function () {
|
||||
return OAuthClient.count()
|
||||
}
|
||||
|
||||
loadFirstClient = function (callback: OAuthClientMethods.LoadFirstClientCallback) {
|
||||
return OAuthClient.findOne().asCallback(callback)
|
||||
loadFirstClient = function () {
|
||||
return OAuthClient.findOne()
|
||||
}
|
||||
|
||||
getByIdAndSecret = function (clientId: string, clientSecret: string) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as Sequelize from 'sequelize'
|
||||
import * as Bluebird from 'bluebird'
|
||||
import * as Promise from 'bluebird'
|
||||
|
||||
import { UserModel } from '../user'
|
||||
|
||||
|
@ -15,12 +15,11 @@ export type OAuthTokenInfo = {
|
|||
}
|
||||
|
||||
export namespace OAuthTokenMethods {
|
||||
export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Bluebird<OAuthTokenInfo>
|
||||
export type GetByTokenAndPopulateUser = (bearerToken: string) => Bluebird<OAuthTokenInstance>
|
||||
export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Bluebird<OAuthTokenInstance>
|
||||
export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Promise<OAuthTokenInfo>
|
||||
export type GetByTokenAndPopulateUser = (bearerToken: string) => Promise<OAuthTokenInstance>
|
||||
export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Promise<OAuthTokenInstance>
|
||||
|
||||
export type RemoveByUserIdCallback = (err: Error) => void
|
||||
export type RemoveByUserId = (userId, callback) => void
|
||||
export type RemoveByUserId = (userId) => Promise<number>
|
||||
}
|
||||
|
||||
export interface OAuthTokenClass {
|
||||
|
|
|
@ -4,7 +4,6 @@ import { logger } from '../../helpers'
|
|||
|
||||
import { addMethodsToModel } from '../utils'
|
||||
import {
|
||||
OAuthTokenClass,
|
||||
OAuthTokenInstance,
|
||||
OAuthTokenAttributes,
|
||||
|
||||
|
@ -149,12 +148,12 @@ getByRefreshTokenAndPopulateUser = function (refreshToken: string) {
|
|||
})
|
||||
}
|
||||
|
||||
removeByUserId = function (userId, callback) {
|
||||
removeByUserId = function (userId: number) {
|
||||
const query = {
|
||||
where: {
|
||||
userId: userId
|
||||
}
|
||||
}
|
||||
|
||||
return OAuthToken.destroy(query).asCallback(callback)
|
||||
return OAuthToken.destroy(query)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue