2021-08-19 14:55:45 +02:00
|
|
|
import define from '../../define';
|
|
|
|
import { Pages } from '@/models/index';
|
2020-11-17 06:59:15 +01:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['pages'],
|
|
|
|
|
|
|
|
requireCredential: false as const,
|
|
|
|
|
|
|
|
res: {
|
|
|
|
type: 'array' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
items: {
|
|
|
|
type: 'object' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
|
|
|
ref: 'Page',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default define(meta, async (ps, me) => {
|
|
|
|
const query = Pages.createQueryBuilder('page')
|
|
|
|
.where('page.visibility = \'public\'')
|
|
|
|
.andWhere('page.likedCount > 0')
|
|
|
|
.orderBy('page.likedCount', 'DESC');
|
|
|
|
|
|
|
|
const pages = await query.take(10).getMany();
|
|
|
|
|
|
|
|
return await Pages.packMany(pages, me);
|
|
|
|
});
|