mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
23 lines
627 B
TypeScript
23 lines
627 B
TypeScript
import { Community as DbCommunity } from '@entity/Community'
|
|
import { Resolver, Query, Authorized } from 'type-graphql'
|
|
|
|
import { Community } from '@model/Community'
|
|
|
|
import { RIGHTS } from '@/auth/RIGHTS'
|
|
|
|
@Resolver()
|
|
export class CommunityResolver {
|
|
@Authorized([RIGHTS.COMMUNITIES])
|
|
@Query(() => [Community])
|
|
async getCommunities(): Promise<Community[]> {
|
|
const dbCommunities: DbCommunity[] = await DbCommunity.find({
|
|
order: {
|
|
foreign: 'ASC',
|
|
createdAt: 'DESC',
|
|
lastAnnouncedAt: 'DESC',
|
|
},
|
|
})
|
|
return dbCommunities.map((dbCom: DbCommunity) => new Community(dbCom))
|
|
}
|
|
}
|