Skip to content

Commit

Permalink
Merge pull request #14 from starshipapp/main
Browse files Browse the repository at this point in the history
Pull 0.9 into stable branch
  • Loading branch information
143mailliw authored Jan 2, 2022
2 parents bc040ed + d40d38d commit 5507599
Show file tree
Hide file tree
Showing 71 changed files with 7,220 additions and 2,734 deletions.
6 changes: 0 additions & 6 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ SITE_URL="http://localhost:3000"
# SMTP_PASSWORD=""
# MAIL_FROM=""

# Uncomment this block to enable HTTPS
# HTTPS_PORT=443
# SSL_PRIVATE_PATH=/path/to/key.key
# SSL_CERTIFICATE_PATH=/path/to/cert.crt
# SSL_CA_PATH=/path/to/ca.crt

# Uncomment this line to enable recaptcha support
# RECAPTCHA_SECRET=""

Expand Down
5,492 changes: 3,052 additions & 2,440 deletions package-lock.json

Large diffs are not rendered by default.

54 changes: 30 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,50 @@
},
"homepage": "https://github.com/starshipapp/starship-server#readme",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"concurrently": "^5.3.0",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"concurrently": "^6.2.1",
"cpy-cli": "^3.1.1",
"del-cli": "^3.0.0",
"eslint": "^7.12.1",
"eslint-plugin-jsdoc": "^30.7.6",
"eslint-plugin-prefer-arrow": "^1.2.2",
"del-cli": "^4.0.1",
"eslint": "^7.32.0",
"eslint-plugin-jsdoc": "^36.0.8",
"eslint-plugin-prefer-arrow": "^1.2.3",
"npm-run-all": "^4.1.5",
"ts-node": "^9.1.1",
"typescript": "^4.0.3"
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
},
"dependencies": {
"@types/bcrypt": "^3.0.0",
"@types/jsonwebtoken": "^8.5.0",
"@types/node": "^14.14.41",
"@graphql-tools/schema": "^8.2.0",
"@types/archiver": "^5.1.1",
"@types/bcrypt": "^5.0.0",
"@types/jsonwebtoken": "^8.5.5",
"@types/node": "^16.7.10",
"@types/node-emoji": "^1.8.1",
"@types/nodemailer": "^6.4.0",
"apollo-server-cache-redis": "^1.3.0",
"apollo-server-express": "^2.18.2",
"aws-sdk": "^2.820.0",
"axios": "^0.21.1",
"bcrypt": "^5.0.0",
"@types/nodemailer": "^6.4.4",
"apollo-server-cache-redis": "^3.1.0",
"apollo-server-express": "^3.3.0",
"archiver": "^5.3.0",
"aws-sdk": "^2.983.0",
"axios": "^0.21.3",
"bcrypt": "^5.0.1",
"dataloader": "^2.0.0",
"dotenv": "^8.2.0",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"graphql": "^15.3.0",
"graphql": "^15.5.2",
"graphql-redis-subscriptions": "^2.4.0",
"graphql-subscriptions": "^1.2.1",
"jsonwebtoken": "^8.5.1",
"log4js": "^6.3.0",
"mongoose": "^5.12.3",
"mongoose": "^6.0.4",
"mongoose-nanoid": "^1.0.4",
"nanoid": "^2.1.11",
"node-emoji": "^1.10.0",
"node-emoji": "^1.11.0",
"node-pre-gyp": "^0.15.0",
"nodemailer": "^6.4.17",
"nodemailer": "^6.6.3",
"otplib": "^12.0.1",
"rebuild": "^0.1.2",
"uuidv4": "^6.2.6",
"subscriptions-transport-ws": "^0.9.19",
"uuidv4": "^6.2.12",
"yn": "^4.0.0"
}
}
3 changes: 3 additions & 0 deletions src/Loggers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {Logger, getLogger} from "log4js";

/**
* Object storing the loggers for global use.
*/
export default class Loggers {
static mainLogger: Logger = getLogger("main");
static dbLogger: Logger = getLogger("database");
Expand Down
24 changes: 24 additions & 0 deletions src/database/Attachments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Document, model, Schema } from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface IAttachment extends Document {
/** The attachment's ID. */
_id: string,
/** The attachment's filename. */
name: string,
/** The attachment's content type. */
type: string,
/** The attachment's URL. */
url: string
}

const attachmentSchema: Schema = new Schema({
_id: String,
name: String,
type: String,
url: String,
});

attachmentSchema.plugin(nanoIdPlugin, 16);

export default model<IAttachment>('attachments', attachmentSchema);
30 changes: 30 additions & 0 deletions src/database/CustomEmojis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {model, Schema, Document} from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface ICustomEmoji extends Document {
/** The emoji's ID. */
_id: string,
/** The ID of the owner of the emoji. */
owner: string,
/** The planet the emoji is from, if it is a planet emoji. */
planet: string,
/** The user the emoji is from, if it is a user emoji. */
user: string,
/** The name of the emoji. */
name: string,
/** The URL of the emoji. */
url: string
}

const customEmojiSchema: Schema = new Schema({
_id: String,
owner: String,
planet: String,
user: String,
name: String,
url: String
});

customEmojiSchema.plugin(nanoIdPlugin, 16);

export default model<ICustomEmoji>('customemojis', customEmojiSchema);
4 changes: 4 additions & 0 deletions src/database/Invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import {model, Schema, Document} from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface IInvite extends Document {
/** The invite's ID. */
_id: string,
/** The ID of the target planet. */
planet: string,
/** The ID of the user who created the invite. */
owner: string,
/** The creation date of the invite. */
createdAt: Date
}

Expand Down
30 changes: 30 additions & 0 deletions src/database/Notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {model, Schema, Document} from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface INotification extends Document {
/** The notification's ID. */
_id: string,
/** The ID of the recipient. */
user: string,
/** The creation date of the notification. */
createdAt: Date,
/** The notification's icon. */
icon: string,
/** The content of the notification. */
text: string,
/** Whether or not the notification is read. */
isRead: boolean
}

const notificationSchema: Schema = new Schema({
_id: String,
user: String,
createdAt: {type: Date, expires: 15780000, default: Date.now()},
icon: String,
text: String,
isRead: {type: Boolean, default: false}
});

notificationSchema.plugin(nanoIdPlugin, 16);

export default model<INotification>('notifications', notificationSchema);
19 changes: 18 additions & 1 deletion src/database/Planets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,37 @@ import {model, Schema, Document} from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface IPlanet extends Document {
/** The planet's ID. */
_id: string,
/** The planet's name. */
name: string,
/** The creation date of the planet. */
createdAt: Date,
/** The ID of the owner of the planet. */
owner: string,
/** Whether or not the planet is private. */
private: boolean,
/** The amount of followers the planet has. */
followerCount: number,
/** The components of the planet. */
components: [{name: string, componentId: string, type: string}],
/** The planet's home component. */
homeComponent: {componentId: string, type: string},
/** Whether or not the planet is featured. */
featured: boolean,
/** Whether or not the planet is verified. */
verified: boolean,
/** Whether or not the planet is partnered. */
partnered: boolean,
/** The description of the planet used on the Featured Planets page. */
featuredDescription: string,
/** An array of the IDs of the users banned from the planet. */
banned: [string],
/** An array of the IDs of the users who are members of the planet. */
members: [string],
/** The planet's custom CSS. */
css: string,
/** The planet's description. */
description: string
}

Expand All @@ -36,7 +52,8 @@ const planetSchema: Schema = new Schema({
banned: [String],
members: [String],
css: String,
description: String
description: String,
lastRead: [{channelId: String, date: Date}]
});

planetSchema.plugin(nanoIdPlugin, 16);
Expand Down
20 changes: 20 additions & 0 deletions src/database/ReadReceipts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Document, model, Schema } from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface IReadReceipt extends Document {
_id: string,
planet: string,
user: string,
lastRead: [{channelId: string, date: Date}]
}

const readReceiptSchema: Schema = new Schema({
_id: String,
user: String,
planet: String,
lastRead: [{channelId: String, date: Date}]
});

readReceiptSchema.plugin(nanoIdPlugin, 16);

export default model<IReadReceipt>('readreceipts', readReceiptSchema);
9 changes: 9 additions & 0 deletions src/database/Reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ import {model, Schema, Document} from "mongoose";
import nanoIdPlugin from "mongoose-nanoid";

export interface IReport extends Document {
/** The report's ID. */
_id: string,
/** The ID of the owner of the report. */
owner: string,
/** The creation date of the report. */
createdAt: Date,
/** The type of object being reported. */
objectType: number,
/** The ID of the object being reported. */
objectId: string,
/** The type of the report. */
reportType: number,
/** The report's message. */
details: string,
/** The ID of the user being reported. */
userId: string,
/** Whether the report is resolved. */
solved: boolean
}

Expand Down
39 changes: 37 additions & 2 deletions src/database/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,60 @@ import {model, Schema, Document} from "mongoose";
// import idPlugin from "./idPlugin";
import nanoIdPlugin from "mongoose-nanoid";

/**
* Object used to filter the user document when sent to a client.
*/
export const safeUserFields = {
_id: true,
username: true,
createdAt: true,
profilePicture: true,
profileBanner: true,
profileBio: true,
banned: true,
admin: true,
sessions: true
};

export interface IUser extends Document {
/** The user's ID. */
_id: string,
/** The associated login services. Only includes password logins currently. */
services: {password: {bcrypt?: string, resetToken?: string, resetExpiry?: Date}},
/** The user's username. */
username: string,
/** The registration date of the user. */
createdAt: Date,
/** The user's profile picture. */
profilePicture: string,
/** The user's email information. There is currently no way to change this. */
emails: [{address: string, verified: boolean, verificationToken?: string}],
/** An array of IDs representing the followed planets. */
following: [string],
/** Whether the user is banned. */
banned: boolean,
/** Whether the user is an admin. */
admin: boolean,
/** How many bytes the user has uploaded. */
usedBytes: number,
/** Whether or not the upload cap is waived. */
capWaived: boolean,
/** The user's Two Factor Authentication secret. */
tfaSecret: string,
/** Whether or not the user has 2FA enabled. */
tfaEnabled: boolean,
backupCodes: [number]
/** The user's 2FA backup codes. */
backupCodes: [number],
/** The user's profile banner. */
profileBanner: string,
/** The user's profile bio. */
profileBio: string,
/** An array of UUIDs representing the servers the user is currently connected to. */
sessions: [string],
/** An array of IDs representing the users the user has blocked. */
blocked: [string],
/** The user's current notification settings. */
notificationSetting: number
}

const userSchema: Schema = new Schema({
Expand All @@ -42,7 +72,12 @@ const userSchema: Schema = new Schema({
capWaived: Boolean,
tfaSecret: String,
tfaEnabled: {type: Boolean, default: false},
backupCodes: [Number]
backupCodes: [Number],
profileBanner: String,
profileBio: String,
sessions: {type: [String], default: []},
blocked: {type: [String], default: []},
notificationSetting: {type: Number, default: 1}
});

userSchema.plugin(nanoIdPlugin, 16);
Expand Down
6 changes: 6 additions & 0 deletions src/database/components/Pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import nanoIdPlugin from "mongoose-nanoid";
import { IComponent } from "./IComponent";

export interface IPage extends IComponent {
/** The page's ID. */
_id: string,
/** The creation date of the page. */
createdAt: Date,
/** The ID of the user who created the page. */
owner: string,
/** The last modification date of the page. */
updatedAt: Date,
/** The ID of the planet the page belongs to. */
planet: string,
/** The page's content. */
content: string
}

Expand Down
Loading

0 comments on commit 5507599

Please sign in to comment.