diff --git a/src/models/community.ts b/src/models/community.ts index 99ee6b1..7ff1a50 100644 --- a/src/models/community.ts +++ b/src/models/community.ts @@ -1,4 +1,5 @@ import { Schema, model } from 'mongoose'; +import { CommunityData } from '@/types/miiverse/community'; import { ICommunity, ICommunityMethods, CommunityModel, HydratedCommunityDocument } from '@/types/mongoose/community'; const CommunitySchema = new Schema({ @@ -86,14 +87,14 @@ CommunitySchema.method('delUserFavorite', async funct await this.save(); }); -CommunitySchema.method('json', function json(): Record { +CommunitySchema.method('json', function json(): CommunityData { return { community_id: this.community_id, name: this.name, description: this.description, icon: this.icon.replace(/[^A-Za-z0-9+/=\s]/g, ''), icon_3ds: '', - pid: this.owner || '', + pid: this.owner, app_data: this.app_data.replace(/[^A-Za-z0-9+/=\s]/g, ''), is_user_community: '0' }; diff --git a/src/types/miiverse/community.ts b/src/types/miiverse/community.ts new file mode 100644 index 0000000..c68e720 --- /dev/null +++ b/src/types/miiverse/community.ts @@ -0,0 +1,10 @@ +export type CommunityData = { + community_id: string; + name: string; + description: string; + icon: string; + icon_3ds: string; + pid: number; + app_data: string; + is_user_community: string; +}; \ No newline at end of file diff --git a/src/types/mongoose/community.ts b/src/types/mongoose/community.ts index 0b94885..6fcb69d 100644 --- a/src/types/mongoose/community.ts +++ b/src/types/mongoose/community.ts @@ -1,4 +1,5 @@ import { Model, Types, HydratedDocument } from 'mongoose'; +import { CommunityData } from '@/types/miiverse/community'; enum COMMUNITY_TYPE { Main = 0, @@ -34,7 +35,7 @@ export interface ICommunity { export interface ICommunityMethods { addUserFavorite(pid: number): Promise; delUserFavorite(pid: number): Promise; - json(): Record; + json(): CommunityData; } interface ICommunityQueryHelpers {}