なんかもうめっちゃ変えた
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import define from '../../define.js';
|
||||
import { Apps } from '@/models/index.js';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { AppsRepository } from '@/models/index.js';
|
||||
import { AppEntityService } from '@/core/entities/AppEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['account', 'app'],
|
||||
@@ -27,18 +30,28 @@ export const paramDef = {
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const query = {
|
||||
userId: user.id,
|
||||
};
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
@Inject(DI.appsRepository)
|
||||
private appsRepository: AppsRepository,
|
||||
|
||||
const apps = await Apps.find({
|
||||
where: query,
|
||||
take: ps.limit,
|
||||
skip: ps.offset,
|
||||
});
|
||||
private appEntityService: AppEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = {
|
||||
userId: me.id,
|
||||
};
|
||||
|
||||
return await Promise.all(apps.map(app => Apps.pack(app, user, {
|
||||
detail: true,
|
||||
})));
|
||||
});
|
||||
const apps = await this.appsRepository.find({
|
||||
where: query,
|
||||
take: ps.limit,
|
||||
skip: ps.offset,
|
||||
});
|
||||
|
||||
return await Promise.all(apps.map(app => this.appEntityService.pack(app, me, {
|
||||
detail: true,
|
||||
})));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user