iceshrimp-legacy/src/server/api/endpoints/gallery/popular.ts
syuilo fec3c70886
Gallery (#7194)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2021-04-24 22:38:24 +09:00

29 lines
662 B
TypeScript

import define from '../../define';
import { GalleryPosts } from '../../../../models';
export const meta = {
tags: ['gallery'],
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: 'GalleryPost',
}
},
};
export default define(meta, async (ps, me) => {
const query = GalleryPosts.createQueryBuilder('post')
.andWhere('post.likedCount > 0')
.orderBy('post.likedCount', 'DESC');
const posts = await query.take(10).getMany();
return await GalleryPosts.packMany(posts, me);
});