mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
First typescript iteration
This commit is contained in:
parent
d5f345ed4c
commit
65fcc3119c
113 changed files with 1961 additions and 1784 deletions
60
server/models/oauth-client.ts
Normal file
60
server/models/oauth-client.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
module.exports = function (sequelize, DataTypes) {
|
||||
const OAuthClient = sequelize.define('OAuthClient',
|
||||
{
|
||||
clientId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
clientSecret: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
grants: {
|
||||
type: DataTypes.ARRAY(DataTypes.STRING)
|
||||
},
|
||||
redirectUris: {
|
||||
type: DataTypes.ARRAY(DataTypes.STRING)
|
||||
}
|
||||
},
|
||||
{
|
||||
indexes: [
|
||||
{
|
||||
fields: [ 'clientId' ],
|
||||
unique: true
|
||||
},
|
||||
{
|
||||
fields: [ 'clientId', 'clientSecret' ],
|
||||
unique: true
|
||||
}
|
||||
],
|
||||
classMethods: {
|
||||
countTotal,
|
||||
getByIdAndSecret,
|
||||
loadFirstClient
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return OAuthClient
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function countTotal (callback) {
|
||||
return this.count().asCallback(callback)
|
||||
}
|
||||
|
||||
function loadFirstClient (callback) {
|
||||
return this.findOne().asCallback(callback)
|
||||
}
|
||||
|
||||
function getByIdAndSecret (clientId, clientSecret) {
|
||||
const query = {
|
||||
where: {
|
||||
clientId: clientId,
|
||||
clientSecret: clientSecret
|
||||
}
|
||||
}
|
||||
|
||||
return this.findOne(query)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue