import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
import { AccountModel } from '../account/account'
+import * as memoizee from 'memoizee'
-@DefaultScope({
+export const getServerActor = memoizee(async function () {
+ const application = await ApplicationModel.load()
+ if (!application) throw Error('Could not load Application from database.')
+
+ const actor = application.Account.Actor
+ actor.Account = application.Account
+
+ return actor
+}, { promise: true })
+
+@DefaultScope(() => ({
include: [
{
- model: () => AccountModel,
+ model: AccountModel,
required: true
}
]
-})
+}))
@Table({
- tableName: 'application'
+ tableName: 'application',
+ timestamps: false
})
export class ApplicationModel extends Model<ApplicationModel> {