mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-08-20 07:34:06 -05:00
Fixed linting issues
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"main": "./dist/server.js",
|
||||
"scripts": {
|
||||
"lint": "npx eslint .",
|
||||
"build": "npm run clean && npx tsc && npx tsc-alias",
|
||||
"build": "npm run lint && npm run clean && npx tsc && npx tsc-alias",
|
||||
"clean": "rm -rf ./dist",
|
||||
"start": "node .",
|
||||
"start:dev": "NODE_ENV=development node ."
|
||||
|
||||
@@ -2,95 +2,95 @@ import { Schema, model } from 'mongoose';
|
||||
import { ICommunity, ICommunityMethods, CommunityModel } from '@/types/mongoose/community';
|
||||
|
||||
const CommunitySchema = new Schema<ICommunity, CommunityModel, ICommunityMethods>({
|
||||
platform_id: Number,
|
||||
name: String,
|
||||
description: String,
|
||||
open: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
allows_comments: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
/**
|
||||
platform_id: Number,
|
||||
name: String,
|
||||
description: String,
|
||||
open: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
allows_comments: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
/**
|
||||
* 0: Main Community
|
||||
* 1: Sub-Community
|
||||
* 2: Announcement Community
|
||||
* 3: Private Community
|
||||
*/
|
||||
type: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
parent: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
admins: {
|
||||
type: [Number],
|
||||
default: undefined
|
||||
},
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
},
|
||||
empathy_count: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
followers: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
has_shop_page: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
icon: String,
|
||||
title_ids: {
|
||||
type: [String],
|
||||
default: undefined
|
||||
},
|
||||
title_id: {
|
||||
type: [String],
|
||||
default: undefined
|
||||
},
|
||||
community_id: String,
|
||||
olive_community_id: String,
|
||||
is_recommended: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
app_data: String,
|
||||
type: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
parent: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
admins: {
|
||||
type: [Number],
|
||||
default: undefined
|
||||
},
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
},
|
||||
empathy_count: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
followers: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
has_shop_page: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
icon: String,
|
||||
title_ids: {
|
||||
type: [String],
|
||||
default: undefined
|
||||
},
|
||||
title_id: {
|
||||
type: [String],
|
||||
default: undefined
|
||||
},
|
||||
community_id: String,
|
||||
olive_community_id: String,
|
||||
is_recommended: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
app_data: String,
|
||||
});
|
||||
|
||||
CommunitySchema.method('upEmpathy', async function upEmpathy(): Promise<void> {
|
||||
const empathy = this.get('empathy_count');
|
||||
this.set('empathy_count', empathy + 1);
|
||||
this.set('empathy_count', empathy + 1);
|
||||
|
||||
await this.save();
|
||||
await this.save();
|
||||
});
|
||||
|
||||
CommunitySchema.method('downEmpathy', async function downEmpathy(): Promise<void> {
|
||||
const empathy = this.get('empathy_count');
|
||||
this.set('empathy_count', empathy - 1);
|
||||
this.set('empathy_count', empathy - 1);
|
||||
|
||||
await this.save();
|
||||
await this.save();
|
||||
});
|
||||
|
||||
CommunitySchema.method('upFollower', async function upFollower(): Promise<void> {
|
||||
const followers = this.get('followers');
|
||||
this.set('followers', followers + 1);
|
||||
this.set('followers', followers + 1);
|
||||
|
||||
await this.save();
|
||||
await this.save();
|
||||
});
|
||||
|
||||
CommunitySchema.method('downFollower', async function downFollower(): Promise<void> {
|
||||
const followers = this.get('followers');
|
||||
this.set('followers', followers - 1);
|
||||
this.set('followers', followers - 1);
|
||||
|
||||
await this.save();
|
||||
await this.save();
|
||||
});
|
||||
|
||||
export const Community: CommunityModel = model<ICommunity, CommunityModel>('Community', CommunitySchema);
|
||||
@@ -2,55 +2,55 @@ import { Schema, model } from 'mongoose';
|
||||
import { IContent, IContentMethods, ContentModel } from '@/types/mongoose/content';
|
||||
|
||||
const ContentSchema = new Schema<IContent, ContentModel, IContentMethods>({
|
||||
pid: Number,
|
||||
followed_communities: {
|
||||
type: [String],
|
||||
default: [0]
|
||||
},
|
||||
followed_users: {
|
||||
type: [Number],
|
||||
default: [0]
|
||||
},
|
||||
following_users: {
|
||||
type: [Number],
|
||||
default: [0]
|
||||
}
|
||||
pid: Number,
|
||||
followed_communities: {
|
||||
type: [String],
|
||||
default: [0]
|
||||
},
|
||||
followed_users: {
|
||||
type: [Number],
|
||||
default: [0]
|
||||
},
|
||||
following_users: {
|
||||
type: [Number],
|
||||
default: [0]
|
||||
}
|
||||
});
|
||||
|
||||
ContentSchema.method('addToCommunities', async function addToCommunities(postID) {
|
||||
const communities = this.get('followed_communities');
|
||||
communities.addToSet(postID);
|
||||
await this.save();
|
||||
const communities = this.get('followed_communities');
|
||||
communities.addToSet(postID);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
ContentSchema.method('removeFromCommunities', async function removeFromCommunities(postID) {
|
||||
const communities = this.get('followed_communities');
|
||||
communities.pull(postID);
|
||||
await this.save();
|
||||
const communities = this.get('followed_communities');
|
||||
communities.pull(postID);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
ContentSchema.method('addToUsers', async function addToUsers(postID) {
|
||||
const users = this.get('followed_users');
|
||||
users.addToSet(postID);
|
||||
await this.save();
|
||||
const users = this.get('followed_users');
|
||||
users.addToSet(postID);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
ContentSchema.method('removeFromUsers', async function removeFromUsers(postID) {
|
||||
const users = this.get('followed_users');
|
||||
users.pull(postID);
|
||||
await this.save();
|
||||
const users = this.get('followed_users');
|
||||
users.pull(postID);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
ContentSchema.method('addToFollowers', async function addToFollowers(postID) {
|
||||
const users = this.get('following_users');
|
||||
users.addToSet(postID);
|
||||
await this.save();
|
||||
const users = this.get('following_users');
|
||||
users.addToSet(postID);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
ContentSchema.method('removeFromFollowers', async function removeFromFollowers(postID) {
|
||||
const users = this.get('following_users');
|
||||
users.pull(postID);
|
||||
await this.save();
|
||||
const users = this.get('following_users');
|
||||
users.pull(postID);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
export const Content: ContentModel = model<IContent, ContentModel>('Content', ContentSchema);
|
||||
|
||||
@@ -4,58 +4,58 @@ import { Snowflake } from 'node-snowflake';
|
||||
import { IConversation, IConversationMethods, ConversationModel } from '@/types/mongoose/conversation';
|
||||
|
||||
const ConversationSchema = new Schema<IConversation, ConversationModel, IConversationMethods>({
|
||||
id: {
|
||||
type: String,
|
||||
default: Snowflake.nextId()
|
||||
},
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
},
|
||||
last_updated: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
},
|
||||
message_preview: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
users: [{
|
||||
pid: Number,
|
||||
official: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
read: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
}]
|
||||
id: {
|
||||
type: String,
|
||||
default: Snowflake.nextId()
|
||||
},
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
},
|
||||
last_updated: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
},
|
||||
message_preview: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
users: [{
|
||||
pid: Number,
|
||||
official: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
read: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
ConversationSchema.method('newMessage', async function newMessage(message, senderPID) {
|
||||
if(this.users[0].pid === senderPID) {
|
||||
this.users[1].read = false;
|
||||
this.markModified('users[1].read');
|
||||
}
|
||||
else {
|
||||
this.users[0].read = false;
|
||||
this.markModified('users[0].read');
|
||||
}
|
||||
this.set('last_updated', moment(new Date()));
|
||||
this.set('message_preview', message);
|
||||
await this.save();
|
||||
if (this.users[0].pid === senderPID) {
|
||||
this.users[1].read = false;
|
||||
this.markModified('users[1].read');
|
||||
} else {
|
||||
this.users[0].read = false;
|
||||
this.markModified('users[0].read');
|
||||
}
|
||||
this.set('last_updated', moment(new Date()));
|
||||
this.set('message_preview', message);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
ConversationSchema.method('markAsRead', async function markAsRead(pid) {
|
||||
let users = this.get('users');
|
||||
if(users[0].pid === pid)
|
||||
users[0].read = true;
|
||||
else if(users[1].pid === pid)
|
||||
users[1].read = true;
|
||||
this.set('users', users)
|
||||
this.markModified('users');
|
||||
await this.save();
|
||||
const users = this.get('users');
|
||||
if (users[0].pid === pid) {
|
||||
users[0].read = true;
|
||||
} else if (users[1].pid === pid) {
|
||||
users[1].read = true;
|
||||
}
|
||||
this.set('users', users);
|
||||
this.markModified('users');
|
||||
await this.save();
|
||||
});
|
||||
|
||||
export const Conversation: ConversationModel = model<IConversation, ConversationModel>('Conversation', ConversationSchema);
|
||||
@@ -2,14 +2,14 @@ import { Schema, model } from 'mongoose';
|
||||
import { IEndpoint, IEndpointMethods, EndpointModel } from '@/types/mongoose/endpoint';
|
||||
|
||||
const endpointSchema = new Schema<IEndpoint, EndpointModel, IEndpointMethods>({
|
||||
status: Number,
|
||||
server_access_level: String,
|
||||
topics: Boolean,
|
||||
guest_access: Boolean,
|
||||
host: String,
|
||||
api_host: String,
|
||||
portal_host: String,
|
||||
n3ds_host: String
|
||||
status: Number,
|
||||
server_access_level: String,
|
||||
topics: Boolean,
|
||||
guest_access: Boolean,
|
||||
host: String,
|
||||
api_host: String,
|
||||
portal_host: String,
|
||||
n3ds_host: String
|
||||
});
|
||||
|
||||
export const Endpoint: EndpointModel = model<IEndpoint, EndpointModel>('Endpoint', endpointSchema);
|
||||
|
||||
@@ -2,13 +2,13 @@ import { Schema, model } from 'mongoose';
|
||||
import { IReport, IReportMethods, ReportModel } from '@/types/mongoose/report';
|
||||
|
||||
const ReportSchema = new Schema<IReport, ReportModel, IReportMethods>({
|
||||
pid: String,
|
||||
post_id: String,
|
||||
reason: Number,
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: new Date()
|
||||
}
|
||||
pid: String,
|
||||
post_id: String,
|
||||
reason: Number,
|
||||
created_at: {
|
||||
type: Date,
|
||||
default: new Date()
|
||||
}
|
||||
});
|
||||
|
||||
export const Report: ReportModel = model<IReport, ReportModel>('Report', ReportSchema);
|
||||
|
||||
@@ -2,90 +2,90 @@ import { Schema, model } from 'mongoose';
|
||||
import { ISettings, ISettingsMethods, SettingsModel } from '@/types/mongoose/settings';
|
||||
|
||||
const SettingsSchema = new Schema<ISettings, SettingsModel, ISettingsMethods>({
|
||||
pid: Number,
|
||||
screen_name: String,
|
||||
account_status: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
ban_lift_date: Date,
|
||||
ban_reason: String,
|
||||
profile_comment: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
profile_comment_visibility: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
game_skill: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
game_skill_visibility: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
birthday_visibility: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
relationship_visibility: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
country_visibility: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
profile_favorite_community_visibility: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
receive_notifications: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
pid: Number,
|
||||
screen_name: String,
|
||||
account_status: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
ban_lift_date: Date,
|
||||
ban_reason: String,
|
||||
profile_comment: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
profile_comment_visibility: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
game_skill: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
game_skill_visibility: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
birthday_visibility: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
relationship_visibility: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
country_visibility: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
profile_favorite_community_visibility: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
receive_notifications: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
});
|
||||
|
||||
SettingsSchema.method('updateComment', async function updateComment(comment) {
|
||||
this.set('profile_comment', comment);
|
||||
await this.save();
|
||||
this.set('profile_comment', comment);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('updateSkill', async function updateSkill(skill) {
|
||||
this.set('game_skill', skill);
|
||||
await this.save();
|
||||
this.set('game_skill', skill);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('commentVisible', async function commentVisible(active) {
|
||||
this.set('profile_comment_visibility', active);
|
||||
await this.save();
|
||||
this.set('profile_comment_visibility', active);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('skillVisible', async function skillVisible(active) {
|
||||
this.set('game_skill_visibility', active);
|
||||
await this.save();
|
||||
this.set('game_skill_visibility', active);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('birthdayVisible', async function birthdayVisible(active) {
|
||||
this.set('birthday_visibility', active);
|
||||
await this.save();
|
||||
this.set('birthday_visibility', active);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('relationshipVisible', async function relationshipVisible(active) {
|
||||
this.set('relationship_visibility', active);
|
||||
await this.save();
|
||||
this.set('relationship_visibility', active);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('countryVisible', async function countryVisible(active) {
|
||||
this.set('country_visibility', active);
|
||||
await this.save();
|
||||
this.set('country_visibility', active);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
SettingsSchema.method('favCommunityVisible', async function favCommunityVisible(active) {
|
||||
this.set('profile_favorite_community_visibility', active);
|
||||
await this.save();
|
||||
this.set('profile_favorite_community_visibility', active);
|
||||
await this.save();
|
||||
});
|
||||
|
||||
export const Settings: SettingsModel = model<ISettings, SettingsModel>('Settings', SettingsSchema);
|
||||
|
||||
@@ -6,7 +6,7 @@ enum ACCESS_LEVEL {
|
||||
Tester = 1,
|
||||
Mod = 2,
|
||||
Developer = 3
|
||||
};
|
||||
}
|
||||
|
||||
type SERVER_ACCESS_LEVEL = 'prod' | 'test' | 'dev';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user