fix: Fetch app auth clients for app config endpoint

This commit is contained in:
Faruk AYDIN
2024-03-28 21:10:06 +01:00
parent 042ad4cea1
commit 1fe4cc3258
2 changed files with 15 additions and 0 deletions

View File

@@ -3,6 +3,9 @@ import AppConfig from '../../../../models/app-config.js';
export default async (request, response) => {
const appConfig = await AppConfig.query()
.withGraphFetched({
appAuthClients: true,
})
.findOne({
key: request.params.appKey,
})

View File

@@ -1,4 +1,5 @@
import App from './app.js';
import AppAuthClient from './app-auth-client.js';
import Base from './base.js';
class AppConfig extends Base {
@@ -17,6 +18,17 @@ class AppConfig extends Base {
},
};
static relationMappings = () => ({
appAuthClients: {
relation: Base.HasManyRelation,
modelClass: AppAuthClient,
join: {
from: 'app_configs.key',
to: 'app_auth_clients.app_key',
},
},
});
static get virtualAttributes() {
return ['canConnect', 'canCustomConnect'];
}