diff --git a/package.json b/package.json index 7ce720c..7262fc6 100644 --- a/package.json +++ b/package.json @@ -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 ." diff --git a/src/models/community.ts b/src/models/community.ts index 52c13f5..e794703 100644 --- a/src/models/community.ts +++ b/src/models/community.ts @@ -2,95 +2,95 @@ import { Schema, model } from 'mongoose'; import { ICommunity, ICommunityMethods, CommunityModel } from '@/types/mongoose/community'; const CommunitySchema = new Schema({ - 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 { 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 { 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 { 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 { 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('Community', CommunitySchema); \ No newline at end of file diff --git a/src/models/content.ts b/src/models/content.ts index b02d163..9025f72 100644 --- a/src/models/content.ts +++ b/src/models/content.ts @@ -2,55 +2,55 @@ import { Schema, model } from 'mongoose'; import { IContent, IContentMethods, ContentModel } from '@/types/mongoose/content'; const ContentSchema = new Schema({ - 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('Content', ContentSchema); diff --git a/src/models/conversation.ts b/src/models/conversation.ts index 374bbd3..b6705f9 100644 --- a/src/models/conversation.ts +++ b/src/models/conversation.ts @@ -4,58 +4,58 @@ import { Snowflake } from 'node-snowflake'; import { IConversation, IConversationMethods, ConversationModel } from '@/types/mongoose/conversation'; const ConversationSchema = new Schema({ - 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('Conversation', ConversationSchema); \ No newline at end of file diff --git a/src/models/endpoint.ts b/src/models/endpoint.ts index fb07366..d10f331 100644 --- a/src/models/endpoint.ts +++ b/src/models/endpoint.ts @@ -2,14 +2,14 @@ import { Schema, model } from 'mongoose'; import { IEndpoint, IEndpointMethods, EndpointModel } from '@/types/mongoose/endpoint'; const endpointSchema = new Schema({ - 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('Endpoint', endpointSchema); diff --git a/src/models/report.ts b/src/models/report.ts index 1ab2f0c..5fd9ca1 100644 --- a/src/models/report.ts +++ b/src/models/report.ts @@ -2,13 +2,13 @@ import { Schema, model } from 'mongoose'; import { IReport, IReportMethods, ReportModel } from '@/types/mongoose/report'; const ReportSchema = new Schema({ - 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('Report', ReportSchema); diff --git a/src/models/settings.ts b/src/models/settings.ts index 07938da..429db8d 100644 --- a/src/models/settings.ts +++ b/src/models/settings.ts @@ -2,90 +2,90 @@ import { Schema, model } from 'mongoose'; import { ISettings, ISettingsMethods, SettingsModel } from '@/types/mongoose/settings'; const SettingsSchema = new Schema({ - 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('Settings', SettingsSchema); diff --git a/src/types/mongoose/pnid.ts b/src/types/mongoose/pnid.ts index ed4b571..27c6abb 100644 --- a/src/types/mongoose/pnid.ts +++ b/src/types/mongoose/pnid.ts @@ -6,7 +6,7 @@ enum ACCESS_LEVEL { Tester = 1, Mod = 2, Developer = 3 -}; +} type SERVER_ACCESS_LEVEL = 'prod' | 'test' | 'dev';