summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.npmignore1
-rw-r--r--README.md30
-rw-r--r--package-lock.json830
-rw-r--r--package.json23
-rw-r--r--src/Server.ts12
-rw-r--r--src/index.ts36
-rw-r--r--src/middlewares/Authentication.ts2
-rw-r--r--src/middlewares/index.ts10
-rw-r--r--src/routes/auth/login.ts2
-rw-r--r--src/routes/auth/register.ts2
-rw-r--r--src/routes/channels/#channel_id/followers.ts10
-rw-r--r--src/routes/channels/#channel_id/index.ts26
-rw-r--r--src/routes/channels/#channel_id/invites.ts12
-rw-r--r--src/routes/channels/#channel_id/messages/#message_id/crosspost.ts8
-rw-r--r--src/routes/channels/#channel_id/messages/#message_id/index.ts6
-rw-r--r--src/routes/channels/#channel_id/messages/#message_id/reactions.ts6
-rw-r--r--src/routes/channels/#channel_id/messages/bulk-delete.ts6
-rw-r--r--src/routes/channels/#channel_id/messages/index.ts14
-rw-r--r--src/routes/channels/#channel_id/permissions.ts1
-rw-r--r--src/routes/channels/#channel_id/pins.ts1
-rw-r--r--src/routes/channels/#channel_id/recipients.ts1
-rw-r--r--src/routes/channels/#channel_id/typing.ts1
-rw-r--r--src/routes/channels/#channel_id/webhooks.ts23
-rw-r--r--src/routes/guilds/#guild_id/bans.ts8
-rw-r--r--src/routes/guilds/#guild_id/channels.ts2
-rw-r--r--src/routes/guilds/#guild_id/index.ts4
-rw-r--r--src/routes/guilds/#guild_id/members.ts2
-rw-r--r--src/routes/guilds/index.ts4
-rw-r--r--src/routes/invites/index.ts5
-rw-r--r--src/routes/users/#id/index.ts19
-rw-r--r--src/routes/users/@me/channels.ts69
-rw-r--r--src/routes/users/@me/guilds.ts2
-rw-r--r--src/routes/users/@me/index.ts2
-rw-r--r--src/schema/Channel.ts19
-rw-r--r--src/schema/Guild.ts2
-rw-r--r--src/schema/Message.ts2
-rw-r--r--src/schema/User.ts43
-rw-r--r--src/start.ts33
-rw-r--r--src/test/rethink_test.ts.disabled (renamed from src/test/rethink_test.ts)0
-rw-r--r--src/test/test.ts2
-rw-r--r--src/util/Captcha.ts1
-rw-r--r--src/util/Config.ts8
-rw-r--r--src/util/Event.ts2
-rw-r--r--src/util/Member.ts2
-rw-r--r--src/util/User.ts2
-rw-r--r--src/util/instanceOf.ts3
-rw-r--r--tsconfig.json2
47 files changed, 529 insertions, 772 deletions
diff --git a/.npmignore b/.npmignore
new file mode 100644

index 00000000..05a9d0cf --- /dev/null +++ b/.npmignore
@@ -0,0 +1 @@ +!dist/ \ No newline at end of file diff --git a/README.md b/README.md
index bf8eed09..d83120e2 100644 --- a/README.md +++ b/README.md
@@ -1,39 +1,51 @@ # Fosscord API Server -This repository contains the HTTP API Server + +This repository contains the Fosscord HTTP API Server ## Bug Tracker + [Project Board](https://github.com/fosscord/fosscord-api/projects/2) ## API -We use [express](https://expressjs.com/) for the HTTP Server and +We use [express](https://expressjs.com/) for the HTTP Server and [lambert-server](https://www.npmjs.com/package/lambert-server) for route handling and body validation (customized). ## Contribution + You should be familiar with: -- [Git](https://git-scm.com/) -- [NodeJS](https://nodejs.org/) -- [TypeScript](https://www.typescriptlang.org/) -- [MongoDB/mongoose](http://mongoosejs.com/) -and the other technologies we use +- [Git](https://git-scm.com/) +- [NodeJS](https://nodejs.org/) +- [TypeScript](https://www.typescriptlang.org/) +- [MongoDB/mongoose](http://mongoosejs.com/) + +and the other technologies we use ### Getting Started + Clone the Repository: + ```bash git clone https://github.com/fosscord/fosscord-api cd discord-server ``` + #### Install (dev)dependencies: + ```bash npm install npm install --only=dev ``` + #### Starting: + ``` npm start ``` + #### Debugging: + **Vscode:** -The Launch file configuration is in ``./vscode/launch.json``, -so you can just debug the server by pressing ``F5`` or the ``> Launch Server`` button +The Launch file configuration is in `./vscode/launch.json`, +so you can just debug the server by pressing `F5` or the `> Launch Server` button diff --git a/package-lock.json b/package-lock.json
index bd7cb447..ea952617 100644 --- a/package-lock.json +++ b/package-lock.json
@@ -1,22 +1,22 @@ { - "name": "fosscord-api", + "name": "@fosscord/api", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "fosscord-api", + "name": "@fosscord/api", "version": "1.0.0", "hasInstallScript": true, "license": "ISC", "dependencies": { + "@fosscord/server-util": "^1.0.4", "@types/jest": "^26.0.22", "bcrypt": "^5.0.0", "body-parser": "^1.19.0", "dotenv": "^8.2.0", "express": "^4.17.1", "express-validator": "^6.9.2", - "fosscord-server-util": "github:fosscord/fosscord-server-util", "i18next": "^19.8.5", "i18next-http-middleware": "^3.1.0", "i18next-node-fs-backend": "^2.1.3", @@ -580,6 +580,63 @@ "node": ">=0.1.95" } }, + "node_modules/@fosscord/server-util": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.0.4.tgz", + "integrity": "sha512-TZPUNyOF/dxmVLDscUPQXmikKS/K209Itv15TGVYGHovCFVIfHVbfXxa+u7EVseQJvX7BL1Kyd45IWDE0Qy1jA==", + "license": "ISC", + "dependencies": { + "@types/jsonwebtoken": "^8.5.0", + "@types/mongoose-autopopulate": "^0.10.1", + "@types/mongoose-lean-virtuals": "^0.5.1", + "@types/node": "^14.14.25", + "jsonwebtoken": "^8.5.1", + "missing-native-js-functions": "^1.2.2", + "mongodb": "^3.6.6", + "mongoose": "^5.12.3", + "mongoose-autopopulate": "^0.12.3", + "typescript": "^4.1.3" + } + }, + "node_modules/@fosscord/server-util/node_modules/mongodb": { + "version": "3.6.6", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz", + "integrity": "sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==", + "dependencies": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "optional-require": "^1.0.2", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + }, + "engines": { + "node": ">=4" + }, + "optionalDependencies": { + "saslprep": "^1.0.0" + }, + "peerDependenciesMeta": { + "aws4": { + "optional": true + }, + "bson-ext": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "mongodb-extjson": { + "optional": true + }, + "snappy": { + "optional": true + } + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1666,11 +1723,6 @@ "integrity": "sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==", "dev": true }, - "node_modules/@types/tmp": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.0.tgz", - "integrity": "sha512-flgpHJjntpBAdJD43ShRosQvNC0ME97DCfGvZEDlAThQmnerRXrLbX6YgzRBQCZTthET9eAWFAMaYP0m0Y4HzQ==" - }, "node_modules/@types/yargs": { "version": "15.0.13", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.13.tgz", @@ -1867,33 +1919,6 @@ "node": ">=0.4.0" } }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/agent-base/node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/agent-base/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -2341,7 +2366,8 @@ "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true }, "node_modules/bcrypt": { "version": "5.0.0", @@ -2723,23 +2749,6 @@ "node": ">=0.6.19" } }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "engines": { - "node": "*" - } - }, "node_modules/buffer-equal-constant-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", @@ -2851,6 +2860,7 @@ "version": "6.2.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "dev": true, "engines": { "node": ">=10" } @@ -3160,11 +3170,6 @@ "node": ">= 0.8" } }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=" - }, "node_modules/component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -3310,6 +3315,7 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -3951,6 +3957,7 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, "dependencies": { "once": "^1.4.0" } @@ -4478,14 +4485,6 @@ "bser": "2.1.1" } }, - "node_modules/fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "dependencies": { - "pend": "~1.2.0" - } - }, "node_modules/fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -4549,28 +4548,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "node_modules/find-cache-dir": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", - "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", - "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/find-package-json": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/find-package-json/-/find-package-json-1.2.0.tgz", - "integrity": "sha512-+SOGcLGYDJHtyqHd87ysBhmaeQ95oWspDKnMXBrnQ9Eq4OkLNqejgoaD8xVWu6GPa0B6roa6KinCMEMcVeqONw==" - }, "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" @@ -4637,62 +4619,6 @@ "node": ">= 0.6" } }, - "node_modules/fosscord-server-util": { - "version": "1.0.0", - "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#9c62b43664f9808497cdaf5142ef071c4e01275d", - "license": "ISC", - "dependencies": { - "@types/jsonwebtoken": "^8.5.0", - "@types/mongoose-autopopulate": "^0.10.1", - "@types/mongoose-lean-virtuals": "^0.5.1", - "@types/node": "^14.14.25", - "jsonwebtoken": "^8.5.1", - "missing-native-js-functions": "^1.2.2", - "mongodb": "^3.6.6", - "mongoose": "^5.12.3", - "mongoose-autopopulate": "^0.12.3", - "typescript": "^4.1.3" - } - }, - "node_modules/fosscord-server-util/node_modules/mongodb": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz", - "integrity": "sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==", - "dependencies": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "optional-require": "^1.0.2", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - }, - "engines": { - "node": ">=4" - }, - "optionalDependencies": { - "saslprep": "^1.0.0" - }, - "peerDependenciesMeta": { - "aws4": { - "optional": true - }, - "bson-ext": { - "optional": true - }, - "kerberos": { - "optional": true - }, - "mongodb-client-encryption": { - "optional": true - }, - "mongodb-extjson": { - "optional": true - }, - "snappy": { - "optional": true - } - } - }, "node_modules/fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -4712,11 +4638,6 @@ "node": ">= 0.6" } }, - "node_modules/fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, "node_modules/fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -4811,14 +4732,6 @@ "node": ">=8.0.0" } }, - "node_modules/get-port": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz", - "integrity": "sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==", - "engines": { - "node": ">=8" - } - }, "node_modules/get-stream": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", @@ -5141,34 +5054,6 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, - "node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/https-proxy-agent/node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/https-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, "node_modules/human-signals": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", @@ -5229,7 +5114,8 @@ "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true }, "node_modules/ignore-walk": { "version": "3.0.3", @@ -7856,6 +7742,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, "dependencies": { "p-locate": "^4.1.0" }, @@ -7863,14 +7750,6 @@ "node": ">=8" } }, - "node_modules/lockfile": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.4.tgz", - "integrity": "sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA==", - "dependencies": { - "signal-exit": "^3.0.2" - } - }, "node_modules/lodash": { "version": "4.17.20", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", @@ -7927,6 +7806,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, "dependencies": { "yallist": "^4.0.0" }, @@ -7937,7 +7817,8 @@ "node_modules/lru-cache/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true }, "node_modules/magic-string": { "version": "0.23.2", @@ -7952,6 +7833,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, "dependencies": { "semver": "^6.0.0" }, @@ -7963,6 +7845,7 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, "bin": { "semver": "bin/semver.js" } @@ -8001,17 +7884,6 @@ "node": ">=0.10.0" } }, - "node_modules/md5-file": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz", - "integrity": "sha512-xbEFXCYVWrSx/gEKS1VPlg84h/4L20znVIulKw6kMfmBUAZNAnF00eczz9ICMl+/hjQGo5KSXRxbL/47X3rmMw==", - "bin": { - "md5-file": "cli.js" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -8302,103 +8174,6 @@ } } }, - "node_modules/mongodb-memory-server": { - "version": "6.9.3", - "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-6.9.3.tgz", - "integrity": "sha512-VU2ey+fknmZflHltPCznZr9fja8T6K7DTG5m7wSxmQC/Qf/kkKmRGqIPcZoEU5znRR/8m/EaOe+hFWkjmh1W5A==", - "hasInstallScript": true, - "dependencies": { - "mongodb-memory-server-core": "6.9.3" - } - }, - "node_modules/mongodb-memory-server-core": { - "version": "6.9.3", - "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-6.9.3.tgz", - "integrity": "sha512-9ZaWemIQLbu9VG553ksMiV7TNnzICqXhSSQv/7Io6dnuO8VpoLLdd1wIz+r2YuWFP7U159JPWQc8QG9jIL27og==", - "dependencies": { - "@types/tmp": "^0.2.0", - "camelcase": "^6.0.0", - "cross-spawn": "^7.0.3", - "debug": "^4.2.0", - "find-cache-dir": "^3.3.1", - "find-package-json": "^1.2.0", - "get-port": "^5.1.1", - "https-proxy-agent": "^5.0.0", - "lockfile": "^1.0.4", - "md5-file": "^5.0.0", - "mkdirp": "^1.0.4", - "mongodb": "3.6.2", - "semver": "^7.3.2", - "tar-stream": "^2.1.4", - "tmp": "^0.2.1", - "uuid": "8.3.0", - "yauzl": "^2.10.0" - }, - "engines": { - "node": ">=10.15.0" - }, - "optionalDependencies": { - "mongodb": "3.6.2" - } - }, - "node_modules/mongodb-memory-server-core/node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/mongodb-memory-server-core/node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/mongodb-memory-server-core/node_modules/mongodb": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.2.tgz", - "integrity": "sha512-sSZOb04w3HcnrrXC82NEh/YGCmBuRgR+C1hZgmmv4L6dBz4BkRse6Y8/q/neXer9i95fKUBbFi4KgeceXmbsOA==", - "optional": true, - "dependencies": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "require_optional": "^1.0.1", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/mongodb-memory-server-core/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/mongodb-memory-server-core/node_modules/semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/mongoose": { "version": "5.12.3", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.3.tgz", @@ -9144,6 +8919,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, "dependencies": { "p-try": "^2.0.0" }, @@ -9155,6 +8931,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, "dependencies": { "p-limit": "^2.2.0" }, @@ -9166,6 +8943,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, "engines": { "node": ">=6" } @@ -9337,6 +9115,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, "engines": { "node": ">=8" } @@ -9353,6 +9132,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "engines": { "node": ">=8" } @@ -9393,11 +9173,6 @@ "node": ">=0.12" } }, - "node_modules/pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" - }, "node_modules/perf-sym": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/perf-sym/-/perf-sym-2.0.3.tgz", @@ -9477,6 +9252,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, "dependencies": { "find-up": "^4.0.0" }, @@ -10156,11 +9932,6 @@ "node": ">=0.12" } }, - "node_modules/rethinkdb-ts": { - "version": "2.4.8", - "resolved": "https://registry.npmjs.org/rethinkdb-ts/-/rethinkdb-ts-2.4.8.tgz", - "integrity": "sha512-nYcqfE+OYkOUCFklcEPTrYZUhrojLo665SeZ/+AG/7v8Dv9SqMiE+L8wCMSWdutHlbOt+b9cQSa1NZVQ4lkvwA==" - }, "node_modules/rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -10534,6 +10305,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -10545,6 +10317,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "engines": { "node": ">=8" } @@ -11336,44 +11109,6 @@ "node": ">=4.5" } }, - "node_modules/tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dependencies": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tar-stream/node_modules/bl": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", - "integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "node_modules/tar-stream/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -11438,28 +11173,6 @@ "node": ">=0.6.0" } }, - "node_modules/tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "dependencies": { - "rimraf": "^3.0.0" - }, - "engines": { - "node": ">=8.17.0" - } - }, - "node_modules/tmp/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -11945,6 +11658,8 @@ "version": "8.3.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==", + "dev": true, + "optional": true, "bin": { "uuid": "dist/bin/uuid" } @@ -12105,6 +11820,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -12386,15 +12102,6 @@ "node": ">=8" } }, - "node_modules/yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", - "dependencies": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", @@ -12856,6 +12563,38 @@ "minimist": "^1.2.0" } }, + "@fosscord/server-util": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.0.4.tgz", + "integrity": "sha512-TZPUNyOF/dxmVLDscUPQXmikKS/K209Itv15TGVYGHovCFVIfHVbfXxa+u7EVseQJvX7BL1Kyd45IWDE0Qy1jA==", + "requires": { + "@types/jsonwebtoken": "^8.5.0", + "@types/mongoose-autopopulate": "^0.10.1", + "@types/mongoose-lean-virtuals": "^0.5.1", + "@types/node": "^14.14.25", + "jsonwebtoken": "^8.5.1", + "missing-native-js-functions": "^1.2.2", + "mongodb": "^3.6.6", + "mongoose": "^5.12.3", + "mongoose-autopopulate": "^0.12.3", + "typescript": "^4.1.3" + }, + "dependencies": { + "mongodb": { + "version": "3.6.6", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz", + "integrity": "sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==", + "requires": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "optional-require": "^1.0.2", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + } + } + } + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -13747,11 +13486,6 @@ "integrity": "sha512-RJJrrySY7A8havqpGObOB4W92QXKJo63/jFLLgpvOtsGUqbQZ9Sbgl35KMm1DjC6j7AvmmU2bIno+3IyEaemaw==", "dev": true }, - "@types/tmp": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.0.tgz", - "integrity": "sha512-flgpHJjntpBAdJD43ShRosQvNC0ME97DCfGvZEDlAThQmnerRXrLbX6YgzRBQCZTthET9eAWFAMaYP0m0Y4HzQ==" - }, "@types/yargs": { "version": "15.0.13", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.13.tgz", @@ -13912,29 +13646,6 @@ "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", "dev": true }, - "agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "requires": { - "debug": "4" - }, - "dependencies": { - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - } - } - }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -14293,7 +14004,8 @@ "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true }, "bcrypt": { "version": "5.0.0", @@ -14628,20 +14340,6 @@ "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.5.tgz", "integrity": "sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg==" }, - "buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" - }, "buffer-equal-constant-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", @@ -14742,7 +14440,8 @@ "camelcase": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", - "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==" + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "dev": true }, "caniuse-lite": { "version": "1.0.30001204", @@ -14998,11 +14697,6 @@ "delayed-stream": "~1.0.0" } }, - "commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=" - }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -15135,6 +14829,7 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -15702,6 +15397,7 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, "requires": { "once": "^1.4.0" } @@ -16131,14 +15827,6 @@ "bser": "2.1.1" } }, - "fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "requires": { - "pend": "~1.2.0" - } - }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -16194,25 +15882,11 @@ } } }, - "find-cache-dir": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", - "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", - "requires": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - } - }, - "find-package-json": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/find-package-json/-/find-package-json-1.2.0.tgz", - "integrity": "sha512-+SOGcLGYDJHtyqHd87ysBhmaeQ95oWspDKnMXBrnQ9Eq4OkLNqejgoaD8xVWu6GPa0B6roa6KinCMEMcVeqONw==" - }, "find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, "requires": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" @@ -16266,37 +15940,6 @@ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" }, - "fosscord-server-util": { - "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#9c62b43664f9808497cdaf5142ef071c4e01275d", - "from": "fosscord-server-util@github:fosscord/fosscord-server-util", - "requires": { - "@types/jsonwebtoken": "^8.5.0", - "@types/mongoose-autopopulate": "^0.10.1", - "@types/mongoose-lean-virtuals": "^0.5.1", - "@types/node": "^14.14.25", - "jsonwebtoken": "^8.5.1", - "missing-native-js-functions": "^1.2.2", - "mongodb": "^3.6.6", - "mongoose": "^5.12.3", - "mongoose-autopopulate": "^0.12.3", - "typescript": "^4.1.3" - }, - "dependencies": { - "mongodb": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz", - "integrity": "sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==", - "requires": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "optional-require": "^1.0.2", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - } - } - } - }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -16310,11 +15953,6 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, - "fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -16390,11 +16028,6 @@ "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", "dev": true }, - "get-port": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz", - "integrity": "sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==" - }, "get-stream": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", @@ -16647,30 +16280,6 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, - "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "requires": { - "agent-base": "6", - "debug": "4" - }, - "dependencies": { - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - } - } - }, "human-signals": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", @@ -16725,7 +16334,8 @@ "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true }, "ignore-walk": { "version": "3.0.3", @@ -18736,18 +18346,11 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, "requires": { "p-locate": "^4.1.0" } }, - "lockfile": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.4.tgz", - "integrity": "sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA==", - "requires": { - "signal-exit": "^3.0.2" - } - }, "lodash": { "version": "4.17.20", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", @@ -18804,6 +18407,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, "requires": { "yallist": "^4.0.0" }, @@ -18811,7 +18415,8 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true } } }, @@ -18828,6 +18433,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, "requires": { "semver": "^6.0.0" }, @@ -18835,7 +18441,8 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true } } }, @@ -18867,11 +18474,6 @@ "object-visit": "^1.0.0" } }, - "md5-file": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz", - "integrity": "sha512-xbEFXCYVWrSx/gEKS1VPlg84h/4L20znVIulKw6kMfmBUAZNAnF00eczz9ICMl+/hjQGo5KSXRxbL/47X3rmMw==" - }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -19095,80 +18697,6 @@ "saslprep": "^1.0.0" } }, - "mongodb-memory-server": { - "version": "6.9.3", - "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-6.9.3.tgz", - "integrity": "sha512-VU2ey+fknmZflHltPCznZr9fja8T6K7DTG5m7wSxmQC/Qf/kkKmRGqIPcZoEU5znRR/8m/EaOe+hFWkjmh1W5A==", - "requires": { - "mongodb-memory-server-core": "6.9.3" - } - }, - "mongodb-memory-server-core": { - "version": "6.9.3", - "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-6.9.3.tgz", - "integrity": "sha512-9ZaWemIQLbu9VG553ksMiV7TNnzICqXhSSQv/7Io6dnuO8VpoLLdd1wIz+r2YuWFP7U159JPWQc8QG9jIL27og==", - "requires": { - "@types/tmp": "^0.2.0", - "camelcase": "^6.0.0", - "cross-spawn": "^7.0.3", - "debug": "^4.2.0", - "find-cache-dir": "^3.3.1", - "find-package-json": "^1.2.0", - "get-port": "^5.1.1", - "https-proxy-agent": "^5.0.0", - "lockfile": "^1.0.4", - "md5-file": "^5.0.0", - "mkdirp": "^1.0.4", - "mongodb": "3.6.2", - "semver": "^7.3.2", - "tar-stream": "^2.1.4", - "tmp": "^0.2.1", - "uuid": "8.3.0", - "yauzl": "^2.10.0" - }, - "dependencies": { - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", - "requires": { - "ms": "2.1.2" - } - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" - }, - "mongodb": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.2.tgz", - "integrity": "sha512-sSZOb04w3HcnrrXC82NEh/YGCmBuRgR+C1hZgmmv4L6dBz4BkRse6Y8/q/neXer9i95fKUBbFi4KgeceXmbsOA==", - "optional": true, - "requires": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "require_optional": "^1.0.1", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, "mongoose": { "version": "5.12.3", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.3.tgz", @@ -19767,6 +19295,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, "requires": { "p-try": "^2.0.0" } @@ -19775,6 +19304,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, "requires": { "p-limit": "^2.2.0" } @@ -19782,7 +19312,8 @@ "p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true }, "pako": { "version": "1.0.11", @@ -19916,7 +19447,8 @@ "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true }, "path-is-absolute": { "version": "1.0.1", @@ -19926,7 +19458,8 @@ "path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true }, "path-parse": { "version": "1.0.6", @@ -19958,11 +19491,6 @@ "sha.js": "^2.4.8" } }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" - }, "perf-sym": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/perf-sym/-/perf-sym-2.0.3.tgz", @@ -20028,6 +19556,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, "requires": { "find-up": "^4.0.0" } @@ -20584,11 +20113,6 @@ "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" }, - "rethinkdb-ts": { - "version": "2.4.8", - "resolved": "https://registry.npmjs.org/rethinkdb-ts/-/rethinkdb-ts-2.4.8.tgz", - "integrity": "sha512-nYcqfE+OYkOUCFklcEPTrYZUhrojLo665SeZ/+AG/7v8Dv9SqMiE+L8wCMSWdutHlbOt+b9cQSa1NZVQ4lkvwA==" - }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -20901,6 +20425,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "requires": { "shebang-regex": "^3.0.0" } @@ -20908,7 +20433,8 @@ "shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true }, "shell-quote": { "version": "1.7.2", @@ -21560,40 +21086,6 @@ "yallist": "^3.0.3" } }, - "tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "dependencies": { - "bl": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", - "integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==", - "requires": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -21646,24 +21138,6 @@ "process": "~0.11.0" } }, - "tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "requires": { - "rimraf": "^3.0.0" - }, - "dependencies": { - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "requires": { - "glob": "^7.1.3" - } - } - } - }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -22047,7 +21521,9 @@ "uuid": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==" + "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==", + "dev": true, + "optional": true }, "v8-to-istanbul": { "version": "7.1.1", @@ -22185,6 +21661,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "requires": { "isexe": "^2.0.0" } @@ -22401,15 +21878,6 @@ } } }, - "yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", - "requires": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, "yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", diff --git a/package.json b/package.json
index 2047cb37..f8509916 100644 --- a/package.json +++ b/package.json
@@ -1,35 +1,42 @@ { - "name": "fosscord-api", + "name": "@fosscord/api", "version": "1.0.0", "description": "This repository contains the HTTP API Server", - "main": "index.js", + "main": "dist/Server.js", + "types": "dist/Server.d.ts", "scripts": { "test": "jest", "test:watch": "jest --watch", - "start": "npm run build:util && npm run build && node dist/", + "start": "npm run build:util && npm run build && node dist/start", "build": "tsc -b .", - "build:util": "tsc -b ./node_modules/fosscord-server-util/", - "postinstall": "npm i github:fosscord/fosscord-server-util && patch-package" + "build:util": "tsc -b ./node_modules/@fosscord/server-util/", + "postinstall": "patch-package" }, "repository": { "type": "git", "url": "git+https://github.com/fosscord/fosscord-api.git" }, - "keywords": [], - "author": "", + "keywords": [ + "discord", + "fosscord", + "fosscord-api", + "discord open source", + "discord-open-source" + ], + "author": "Fosscord", "license": "ISC", "bugs": { "url": "https://github.com/fosscord/fosscord-api/issues" }, "homepage": "https://github.com/fosscord/fosscord-api#readme", "dependencies": { + "@fosscord/server-util": "^1.0.4", "@types/jest": "^26.0.22", "bcrypt": "^5.0.0", "body-parser": "^1.19.0", "dotenv": "^8.2.0", "express": "^4.17.1", "express-validator": "^6.9.2", - "fosscord-server-util": "github:fosscord/fosscord-server-util", "i18next": "^19.8.5", "i18next-http-middleware": "^3.1.0", "i18next-node-fs-backend": "^2.1.3", diff --git a/src/Server.ts b/src/Server.ts
index 19a0fc5f..c7c52c1f 100644 --- a/src/Server.ts +++ b/src/Server.ts
@@ -4,7 +4,7 @@ import { Connection } from "mongoose"; import { Server, ServerOptions } from "lambert-server"; import { Authentication, GlobalRateLimit } from "./middlewares/"; import Config from "./util/Config"; -import { db } from "fosscord-server-util"; +import { db } from "@fosscord/server-util"; import i18next from "i18next"; import i18nextMiddleware, { I18next } from "i18next-http-middleware"; import i18nextBackend from "i18next-node-fs-backend"; @@ -13,21 +13,21 @@ import { BodyParser } from "./middlewares/BodyParser"; import { Router } from "express"; import fetch from "node-fetch"; -export interface DiscordServerOptions extends ServerOptions {} +export interface FosscordServerOptions extends ServerOptions {} declare global { namespace Express { interface Request { // @ts-ignore - server: DiscordServer; + server: FosscordServer; } } } -export class DiscordServer extends Server { - public options: DiscordServerOptions; +export class FosscordServer extends Server { + public options: FosscordServerOptions; - constructor(opts?: Partial<DiscordServerOptions>) { + constructor(opts?: Partial<FosscordServerOptions>) { // @ts-ignore super({ ...opts, errorHandler: false, jsonBody: false }); } diff --git a/src/index.ts b/src/index.ts
index 6a0fabc4..c6417126 100644 --- a/src/index.ts +++ b/src/index.ts
@@ -1,17 +1,19 @@ -process.on("uncaughtException", console.error); -process.on("unhandledRejection", console.error); - -import "missing-native-js-functions"; -import { config } from "dotenv"; -config(); -import { DiscordServer } from "./Server"; - -var port = Number(process.env.PORT); -if (isNaN(port)) port = 1000; - -const server = new DiscordServer({ port }); -server.start().catch(console.error); - -// @ts-ignore -global.server = server; -export default server; +export * from "./Server"; +export * from "./middlewares/"; +export * from "./schema/Ban"; +export * from "./schema/Channel"; +export * from "./schema/Guild"; +export * from "./schema/Invite"; +export * from "./schema/Message"; +export * from "./util/Captcha"; +export * from "./util/Config"; +export * from "./util/Constants"; +export * from "./util/Event"; +export * from "./util/instanceOf"; +export * from "./util/Event"; +export * from "./util/instanceOf"; +export * from "./util/Member"; +export * from "./util/RandomInviteID"; +export * from "./util/String"; +export * from "./util/User"; +export { check as checkPassword } from "./util/passwordStrength"; diff --git a/src/middlewares/Authentication.ts b/src/middlewares/Authentication.ts
index 30445815..0ecc1bc0 100644 --- a/src/middlewares/Authentication.ts +++ b/src/middlewares/Authentication.ts
@@ -1,6 +1,6 @@ import { NextFunction, Request, Response } from "express"; import { HTTPError } from "lambert-server"; -import { checkToken } from "fosscord-server-util"; +import { checkToken } from "@fosscord/server-util"; export const NO_AUTHORIZATION_ROUTES = [ "/api/v8/auth/login", diff --git a/src/middlewares/index.ts b/src/middlewares/index.ts
index e3332f07..6a2993a7 100644 --- a/src/middlewares/index.ts +++ b/src/middlewares/index.ts
@@ -1,4 +1,6 @@ -import { Authentication } from "./Authentication"; -import { GlobalRateLimit } from "./GlobalRateLimit"; - -export { Authentication, GlobalRateLimit }; +export * from "./GlobalRateLimit"; +export * from "./Authentication"; +export * from "./BodyParser"; +export * from "./CORS"; +export * from "./ErrorHandler"; +export * from "./RateLimit"; diff --git a/src/routes/auth/login.ts b/src/routes/auth/login.ts
index cc2b6202..247ee018 100644 --- a/src/routes/auth/login.ts +++ b/src/routes/auth/login.ts
@@ -2,7 +2,7 @@ import { Request, Response, Router } from "express"; import { check, FieldErrors, Length } from "../../util/instanceOf"; import bcrypt from "bcrypt"; import jwt from "jsonwebtoken"; -import { User, UserModel } from "fosscord-server-util"; +import { UserModel } from "@fosscord/server-util"; import Config from "../../util/Config"; import { adjustEmail } from "./register"; diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts
index 5501203d..1a026670 100644 --- a/src/routes/auth/register.ts +++ b/src/routes/auth/register.ts
@@ -1,6 +1,6 @@ import { Request, Response, Router } from "express"; import Config from "../../util/Config"; -import { trimSpecial, User, Snowflake, UserModel } from "fosscord-server-util"; +import { trimSpecial, User, Snowflake, UserModel } from "@fosscord/server-util"; import bcrypt from "bcrypt"; import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../util/instanceOf"; import "missing-native-js-functions"; diff --git a/src/routes/channels/#channel_id/followers.ts b/src/routes/channels/#channel_id/followers.ts
index 9a4e81fa..c06db61b 100644 --- a/src/routes/channels/#channel_id/followers.ts +++ b/src/routes/channels/#channel_id/followers.ts
@@ -1,4 +1,14 @@ import { Router } from "express"; const router: Router = Router(); +// TODO: export default router; + +/** + * + * @param {"webhook_channel_id":"754001514330062952"} + * + * Creates a WebHook in the channel and returns the id of it + * + * @returns {"channel_id": "816382962056560690", "webhook_id": "834910735095037962"} + */ diff --git a/src/routes/channels/#channel_id/index.ts b/src/routes/channels/#channel_id/index.ts
index 9a4e81fa..f6970df3 100644 --- a/src/routes/channels/#channel_id/index.ts +++ b/src/routes/channels/#channel_id/index.ts
@@ -1,4 +1,30 @@ +import { ChannelModel, getPermission, toObject } from "@fosscord/server-util"; import { Router } from "express"; +import { HTTPError } from "lambert-server"; const router: Router = Router(); +// TODO: delete channel +// TODO: Get channel + +router.delete("/", async(req,res)=>{ + const {channel_id} = req.params + + const channel = await ChannelModel.findOne({ id: channel_id }, { guild_id: true, type: true, permission_overwrites: true }).exec(); + if (!channel) throw new HTTPError("Channel not found", 404); + if (channel.guild_id) { + const permission = await getPermission(req.user_id, channel.guild_id) + permission.hasThrow("MANAGE_CHANNELS") + + // TODO Channel Update Gateway event will fire for each of them + await ChannelModel.updateMany({parent_id: channel_id}, {$set: {channel_id: null}}).exec() + + await ChannelModel.deleteOne({id: channel_id}) + } + + // TODO: Dm channel "close" not delete + + const data = toObject(channel); + //TODO: Reload channel list if request successful + res.send(data) +}) export default router; diff --git a/src/routes/channels/#channel_id/invites.ts b/src/routes/channels/#channel_id/invites.ts
index da802800..10d6ae3f 100644 --- a/src/routes/channels/#channel_id/invites.ts +++ b/src/routes/channels/#channel_id/invites.ts
@@ -7,7 +7,7 @@ import { emitEvent } from "../../../util/Event"; import { InviteCreateSchema } from "../../../schema/Invite"; -import { getPermission, ChannelModel, InviteModel, InviteCreateEvent, toObject } from "fosscord-server-util"; +import { getPermission, ChannelModel, InviteModel, InviteCreateEvent, toObject } from "@fosscord/server-util"; const router: Router = Router(); @@ -22,10 +22,7 @@ router.post("/", check(InviteCreateSchema), async (req: Request, res: Response) const { guild_id } = channel; const permission = await getPermission(user_id, guild_id); - - if (!permission.has("CREATE_INSTANT_INVITE")) { - throw new HTTPError("You aren't authorised to access this endpoint", 401); - } + permission.hasThrow("CREATE_INSTANT_INVITE"); const invite = { code: random(), @@ -55,10 +52,7 @@ router.get("/", async (req: Request, res: Response) => { } const { guild_id } = channel; const permission = await getPermission(user_id, guild_id); - - if (!permission.has("MANAGE_CHANNELS")) { - throw new HTTPError("You aren't authorised to access this endpoint", 401); - } + permission.hasThrow("MANAGE_CHANNELS"); const invites = await InviteModel.find({ guild_id }).exec(); diff --git a/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts new file mode 100644
index 00000000..17f36396 --- /dev/null +++ b/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts
@@ -0,0 +1,8 @@ +import { Router } from "express"; + +const router = Router(); + +// TODO: +// router.post("/", (req, res) => {}); + +export default router; diff --git a/src/routes/channels/#channel_id/messages/#message_id/index.ts b/src/routes/channels/#channel_id/messages/#message_id/index.ts new file mode 100644
index 00000000..014daee7 --- /dev/null +++ b/src/routes/channels/#channel_id/messages/#message_id/index.ts
@@ -0,0 +1,6 @@ +import { Router } from "express"; + +const router = Router(); +// TODO: + +export default router; diff --git a/src/routes/channels/#channel_id/messages/#message_id/reactions.ts b/src/routes/channels/#channel_id/messages/#message_id/reactions.ts new file mode 100644
index 00000000..014daee7 --- /dev/null +++ b/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -0,0 +1,6 @@ +import { Router } from "express"; + +const router = Router(); +// TODO: + +export default router; diff --git a/src/routes/channels/#channel_id/messages/bulk-delete.ts b/src/routes/channels/#channel_id/messages/bulk-delete.ts
index 89e9d720..ff1324d7 100644 --- a/src/routes/channels/#channel_id/messages/bulk-delete.ts +++ b/src/routes/channels/#channel_id/messages/bulk-delete.ts
@@ -1,5 +1,5 @@ import { Router } from "express"; -import { ChannelModel, getPermission, MessageDeleteBulkEvent, MessageModel } from "fosscord-server-util"; +import { ChannelModel, getPermission, MessageDeleteBulkEvent, MessageModel } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import Config from "../../../../util/Config"; import { emitEvent } from "../../../../util/Event"; @@ -13,12 +13,12 @@ export default router; // TODO: should this request fail, if you provide messages older than 14 days/invalid ids? // https://discord.com/developers/docs/resources/channel#bulk-delete-messages router.post("/", check({ messages: [String] }), async (req, res) => { - const channel_id = req.params.channel_id + const channel_id = req.params.channel_id; const channel = await ChannelModel.findOne({ id: channel_id }, { permission_overwrites: true, guild_id: true }).exec(); if (!channel?.guild_id) throw new HTTPError("Can't bulk delete dm channel messages", 400); const permission = await getPermission(req.user_id, channel?.guild_id, channel_id, { channel }); - if (!permission.has("MANAGE_MESSAGES")) throw new HTTPError("You are missing the MANAGE_MESSAGES permissions"); + permission.hasThrow("MANAGE_MESSAGES"); const { maxBulkDelete } = Config.get().limits.message; diff --git a/src/routes/channels/#channel_id/messages/index.ts b/src/routes/channels/#channel_id/messages/index.ts
index c3ea3da9..a5151d9b 100644 --- a/src/routes/channels/#channel_id/messages/index.ts +++ b/src/routes/channels/#channel_id/messages/index.ts
@@ -9,7 +9,7 @@ import { MessageModel, Snowflake, toObject, -} from "fosscord-server-util"; +} from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { MessageCreateSchema } from "../../../../schema/Message"; import { check, instanceOf, Length } from "../../../../util/instanceOf"; @@ -22,7 +22,7 @@ const router: Router = Router(); export default router; -function isTextChannel(type: ChannelType): boolean { +export function isTextChannel(type: ChannelType): boolean { switch (type) { case ChannelType.GUILD_VOICE: case ChannelType.GUILD_CATEGORY: @@ -62,7 +62,8 @@ router.get("/", async (req, res) => { if (channel.guild_id) { const permissions = await getPermission(req.user_id, channel.guild_id, channel_id, { channel }); - if (!permissions.has("VIEW_CHANNEL")) throw new HTTPError("You don't have permission to view this channel", 401); + permissions.hasThrow("VIEW_CHANNEL"); + if (!permissions.has("READ_MESSAGE_HISTORY")) return res.json([]); } else if (channel.recipients) { // group/dm channel @@ -106,11 +107,10 @@ router.post("/", check(MessageCreateSchema), async (req, res) => { if (channel.guild_id) { const permissions = await getPermission(req.user_id, channel.guild_id, channel_id, { channel }); - if (!permissions.has("SEND_MESSAGES")) throw new HTTPError("You don't have the SEND_MESSAGES permission"); - if (body.tts && !permissions.has("SEND_TTS_MESSAGES")) throw new HTTPError("You are missing the SEND_TTS_MESSAGES permission"); + permissions.hasThrow("SEND_MESSAGES"); + if (body.tts) permissions.hasThrow("SEND_TTS_MESSAGES"); if (body.message_reference) { - if (!permissions.has("READ_MESSAGE_HISTORY")) - throw new HTTPError("You are missing the READ_MESSAGE_HISTORY permission to reply"); + permissions.hasThrow("READ_MESSAGE_HISTORY"); if (body.message_reference.guild_id !== channel.guild_id) throw new HTTPError("You can only reference messages from this guild"); } diff --git a/src/routes/channels/#channel_id/permissions.ts b/src/routes/channels/#channel_id/permissions.ts
index 9a4e81fa..93c33ea5 100644 --- a/src/routes/channels/#channel_id/permissions.ts +++ b/src/routes/channels/#channel_id/permissions.ts
@@ -1,4 +1,5 @@ import { Router } from "express"; const router: Router = Router(); +// TODO: export default router; diff --git a/src/routes/channels/#channel_id/pins.ts b/src/routes/channels/#channel_id/pins.ts
index 9a4e81fa..93c33ea5 100644 --- a/src/routes/channels/#channel_id/pins.ts +++ b/src/routes/channels/#channel_id/pins.ts
@@ -1,4 +1,5 @@ import { Router } from "express"; const router: Router = Router(); +// TODO: export default router; diff --git a/src/routes/channels/#channel_id/recipients.ts b/src/routes/channels/#channel_id/recipients.ts
index 9a4e81fa..93c33ea5 100644 --- a/src/routes/channels/#channel_id/recipients.ts +++ b/src/routes/channels/#channel_id/recipients.ts
@@ -1,4 +1,5 @@ import { Router } from "express"; const router: Router = Router(); +// TODO: export default router; diff --git a/src/routes/channels/#channel_id/typing.ts b/src/routes/channels/#channel_id/typing.ts
index 9a4e81fa..93c33ea5 100644 --- a/src/routes/channels/#channel_id/typing.ts +++ b/src/routes/channels/#channel_id/typing.ts
@@ -1,4 +1,5 @@ import { Router } from "express"; const router: Router = Router(); +// TODO: export default router; diff --git a/src/routes/channels/#channel_id/webhooks.ts b/src/routes/channels/#channel_id/webhooks.ts
index 9a4e81fa..a56365b8 100644 --- a/src/routes/channels/#channel_id/webhooks.ts +++ b/src/routes/channels/#channel_id/webhooks.ts
@@ -1,4 +1,27 @@ import { Router } from "express"; +import { check, Length } from "../../../util/instanceOf"; +import { ChannelModel, getPermission, trimSpecial } from "@fosscord/server-util"; +import { HTTPError } from "lambert-server"; +import { isTextChannel } from "./messages/index"; + const router: Router = Router(); +// TODO: + +// TODO: use Image Data Type for avatar instead of String +router.post("/", check({ name: new Length(String, 1, 80), $avatar: String }), async (req, res) => { + const channel_id = req.params.channel_id; + const channel = await ChannelModel.findOne({ id: channel_id }, { guild_id: true, type: true }).exec(); + if (!channel) throw new HTTPError("Channel not found", 404); + + isTextChannel(channel.type); + if (!channel.guild_id) throw new HTTPError("Not a guild channel", 400); + + const permission = await getPermission(req.user_id, channel.guild_id); + permission.hasThrow("MANAGE_WEBHOOKS"); + + var { avatar, name } = req.body as { name: string; avatar?: string }; + name = trimSpecial(name); + if (name === "clyde") throw new HTTPError("Invalid name", 400); +}); export default router; diff --git a/src/routes/guilds/#guild_id/bans.ts b/src/routes/guilds/#guild_id/bans.ts
index 3de80a32..f84950f9 100644 --- a/src/routes/guilds/#guild_id/bans.ts +++ b/src/routes/guilds/#guild_id/bans.ts
@@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { BanModel, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, GuildModel, toObject } from "fosscord-server-util"; +import { BanModel, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, GuildModel, toObject } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { getIpAdress } from "../../../middlewares/GlobalRateLimit"; import { BanCreateSchema } from "../../../schema/Ban"; @@ -35,7 +35,7 @@ router.post("/:user_id", check(BanCreateSchema), async (req: Request, res: Respo const banned_user = await getPublicUser(banned_user_id); const perms = await getPermission(req.user_id, guild_id); - if (!perms.has("BAN_MEMBERS")) throw new HTTPError("You don't have the permission to ban members", 403); + perms.hasThrow("BAN_MEMBERS"); if (req.user_id === banned_user_id) throw new HTTPError("You can't ban yourself", 400); await removeMember(banned_user_id, guild_id); @@ -69,9 +69,7 @@ router.delete("/:user_id", async (req: Request, res: Response) => { if (!guild) throw new HTTPError("Guild not found", 404); const perms = await getPermission(req.user_id, guild_id); - if (!perms.has("BAN_MEMBERS")) { - throw new HTTPError("No permissions", 403); - } + perms.hasThrow("BAN_MEMBERS"); await BanModel.deleteOne({ user_id: banned_user_id, diff --git a/src/routes/guilds/#guild_id/channels.ts b/src/routes/guilds/#guild_id/channels.ts
index e0d8f3ac..d42ba481 100644 --- a/src/routes/guilds/#guild_id/channels.ts +++ b/src/routes/guilds/#guild_id/channels.ts
@@ -1,5 +1,5 @@ import { Router } from "express"; -import { ChannelCreateEvent, ChannelModel, ChannelType, GuildModel, Snowflake, toObject } from "fosscord-server-util"; +import { ChannelCreateEvent, ChannelModel, ChannelType, GuildModel, Snowflake, toObject } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { ChannelModifySchema } from "../../../schema/Channel"; import { emitEvent } from "../../../util/Event"; diff --git a/src/routes/guilds/#guild_id/index.ts b/src/routes/guilds/#guild_id/index.ts
index 7e5f49d3..2a7d9b38 100644 --- a/src/routes/guilds/#guild_id/index.ts +++ b/src/routes/guilds/#guild_id/index.ts
@@ -12,7 +12,7 @@ import { RoleModel, toObject, UserModel, -} from "fosscord-server-util"; +} from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { GuildUpdateSchema } from "../../../schema/Guild"; import { emitEvent } from "../../../util/Event"; @@ -41,7 +41,7 @@ router.patch("/", check(GuildUpdateSchema), async (req: Request, res: Response) // TODO: guild update check image const perms = await getPermission(req.user_id, guild_id); - if (!perms.has("MANAGE_GUILD")) throw new HTTPError("You do not have the MANAGE_GUILD permission", 401); + perms.hasThrow("MANAGE_GUILD"); const guild = await GuildModel.findOneAndUpdate({ id: guild_id }, body) .populate({ path: "joined_at", match: { id: req.user_id } }) diff --git a/src/routes/guilds/#guild_id/members.ts b/src/routes/guilds/#guild_id/members.ts
index f4e6d4e8..61493485 100644 --- a/src/routes/guilds/#guild_id/members.ts +++ b/src/routes/guilds/#guild_id/members.ts
@@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { GuildModel, MemberModel, toObject } from "fosscord-server-util"; +import { GuildModel, MemberModel, toObject } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { instanceOf, Length } from "../../../util/instanceOf"; import { PublicMemberProjection } from "../../../util/Member"; diff --git a/src/routes/guilds/index.ts b/src/routes/guilds/index.ts
index 57d7ddc4..bd491e86 100644 --- a/src/routes/guilds/index.ts +++ b/src/routes/guilds/index.ts
@@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { RoleModel, GuildModel, Snowflake, Guild } from "fosscord-server-util"; +import { RoleModel, GuildModel, Snowflake, Guild } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { check } from "./../../util/instanceOf"; import { GuildCreateSchema } from "../../schema/Guild"; @@ -9,6 +9,8 @@ import { addMember } from "../../util/Member"; const router: Router = Router(); +//TODO: create default channel + router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) => { const body = req.body as GuildCreateSchema; diff --git a/src/routes/invites/index.ts b/src/routes/invites/index.ts
index df74e216..7f4ff59b 100644 --- a/src/routes/invites/index.ts +++ b/src/routes/invites/index.ts
@@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { getPermission, InviteModel, toObject } from "fosscord-server-util"; +import { getPermission, InviteModel, toObject } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; const router: Router = Router(); @@ -21,7 +21,8 @@ router.delete("/:invite_code", async (req: Request, res: Response) => { const { guild_id, channel_id } = invite; const perms = await getPermission(req.user_id, guild_id, channel_id); - if (!perms.has("MANAGE_GUILD") || !perms.has("MANAGE_CHANNELS")) throw new HTTPError("You aren't allow", 401); + if (!perms.has("MANAGE_GUILD") && !perms.has("MANAGE_CHANNELS")) + throw new HTTPError("You missing the MANAGE_GUILD or MANAGE_CHANNELS permission", 401); await InviteModel.deleteOne({ code }).exec(); diff --git a/src/routes/users/#id/index.ts b/src/routes/users/#id/index.ts new file mode 100644
index 00000000..d5f3b788 --- /dev/null +++ b/src/routes/users/#id/index.ts
@@ -0,0 +1,19 @@ +import { Router, Request, Response } from "express"; +import { UserModel, toObject } from "@fosscord/server-util"; +import { getPublicUser } from "../../../util/User"; +import { HTTPError } from "lambert-server"; +import { UserUpdateSchema } from "../../../schema/User"; +import { check } from "../../../util/instanceOf"; + +const router: Router = Router(); + +router.get("/", async (req: Request, res: Response) => { + const { id } = req.params; + const user = await getPublicUser(id); + if (!user) throw new HTTPError("User not found", 404); + + res.json(user); +}); + + +export default router; diff --git a/src/routes/users/@me/channels.ts b/src/routes/users/@me/channels.ts new file mode 100644
index 00000000..45371b34 --- /dev/null +++ b/src/routes/users/@me/channels.ts
@@ -0,0 +1,69 @@ +import { + Router, + Request, + Response +} from "express"; +import { + ChannelModel, + ChannelCreateEvent, + DMChannel, + UserModel, + toObject, + ChannelType, + Snowflake +} from "@fosscord/server-util"; +import { + HTTPError +} from "lambert-server"; +import { + emitEvent +} from "../../../util/Event"; +import { + getPublicUser +} from "../../../util/User"; +import { + DmChannelCreateSchema +} from "../../../schema/Channel"; +import { + check +} from "../../../util/instanceOf"; + +const router: Router = Router(); + +router.get("/", async (req: Request, res: Response) => { + const user = await UserModel.findOne({ + id: req.user_id + }, { + guilds: true + }).exec(); + if (!user) throw new HTTPError("User not found", 404); + + var testID = "829044530203328513"; //FOR TEST + + var channels = await ChannelModel.find({ + recipients: req.user_id, + type: 1 + }).exec(); + + res.json(toObject(channels)); +}); + +router.post("/", check(DmChannelCreateSchema), async (req, res) => { + const body = req.body as DmChannelCreateSchema; + + const channel = { + ...body, + owner_id: req.user_id, + id: Snowflake.generate(), + type: ChannelType.DM, + created_at: new Date(), + }; + await new ChannelModel(channel).save(); + + /*Event({ event: "CHANNEL_CREATE", data: channel } as ChannelCreateEvent);*/ + + + res.json(channel); +}); + +export default router; \ No newline at end of file diff --git a/src/routes/users/@me/guilds.ts b/src/routes/users/@me/guilds.ts
index d0fbaa3e..5042c17c 100644 --- a/src/routes/users/@me/guilds.ts +++ b/src/routes/users/@me/guilds.ts
@@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { GuildModel, MemberModel, UserModel, GuildDeleteEvent, GuildMemberRemoveEvent, toObject } from "fosscord-server-util"; +import { GuildModel, MemberModel, UserModel, GuildDeleteEvent, GuildMemberRemoveEvent, toObject } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import { emitEvent } from "../../../util/Event"; import { getPublicUser } from "../../../util/User"; diff --git a/src/routes/users/@me/index.ts b/src/routes/users/@me/index.ts
index 32877dcc..22d4cf3b 100644 --- a/src/routes/users/@me/index.ts +++ b/src/routes/users/@me/index.ts
@@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { UserModel } from "fosscord-server-util"; +import { UserModel } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; const router: Router = Router(); diff --git a/src/schema/Channel.ts b/src/schema/Channel.ts
index 0fafc54d..3a22872a 100644 --- a/src/schema/Channel.ts +++ b/src/schema/Channel.ts
@@ -1,3 +1,4 @@ +import { ChannelType } from "@fosscord/server-util"; import { Length } from "../util/instanceOf"; export const ChannelModifySchema = { @@ -20,6 +21,24 @@ export const ChannelModifySchema = { $nsfw: Boolean, }; +export const DmChannelCreateSchema = { + owner_id: String, + $id: String, + $created_at: Date, + name: String, + type: Number, + recipients: [String] +} + +export interface DmChannelCreateSchema { + owner_id: String; + id?: String; + created_at?: Date; + name: String; + type: Number; + recipients: String[]; +} + export interface ChannelModifySchema { name: string; type: number; diff --git a/src/schema/Guild.ts b/src/schema/Guild.ts
index 6527f35d..2b792db0 100644 --- a/src/schema/Guild.ts +++ b/src/schema/Guild.ts
@@ -1,4 +1,4 @@ -import { ChannelSchema, GuildChannel } from "fosscord-server-util"; +import { ChannelSchema, GuildChannel } from "@fosscord/server-util"; import { Length } from "../util/instanceOf"; export const GuildCreateSchema = { diff --git a/src/schema/Message.ts b/src/schema/Message.ts
index c0e2315a..9b62edcf 100644 --- a/src/schema/Message.ts +++ b/src/schema/Message.ts
@@ -1,4 +1,4 @@ -import { Embed, EmbedImage } from "fosscord-server-util"; +import { Embed, EmbedImage } from "@fosscord/server-util"; import { Length } from "../util/instanceOf"; export const MessageCreateSchema = { diff --git a/src/schema/User.ts b/src/schema/User.ts new file mode 100644
index 00000000..2b74a433 --- /dev/null +++ b/src/schema/User.ts
@@ -0,0 +1,43 @@ +export const UserUpdateSchema = { + id: String, + username: String, + discriminator: String, + avatar: String || null, + $phone: String, + desktop: Boolean, + mobile: Boolean, + premium: Boolean, + premium_type: Number, + bot: Boolean, + system: Boolean, + nsfw_allowed: Boolean, + mfa_enabled: Boolean, + created_at: Date, + verified: Boolean, + $email: String, + flags: BigInt, + public_flags: BigInt, + $guilds: [String], +}; + +export interface UserUpdateSchema { + id: string; + username: string; + discriminator: string; + avatar: string | null; + phone?: string; + desktop: boolean; + mobile: boolean; + premium: boolean; + premium_type: number; + bot: boolean; + system: boolean; + nsfw_allowed: boolean; + mfa_enabled: boolean; + created_at: Date; + verified: boolean; + email?: string; + flags: bigint; + public_flags: bigint; + guilds: string[]; +} diff --git a/src/start.ts b/src/start.ts new file mode 100644
index 00000000..11e15941 --- /dev/null +++ b/src/start.ts
@@ -0,0 +1,33 @@ +process.on("uncaughtException", console.error); +process.on("unhandledRejection", console.error); + +import "missing-native-js-functions"; +import { config } from "dotenv"; +config(); +import { FosscordServer } from "./Server"; +import cluster from "cluster"; +import os from "os"; +const cores = os.cpus().length; + +if (cluster.isMaster && process.env.production == "true") { + console.log(`Primary ${process.pid} is running`); + + // Fork workers. + for (let i = 0; i < cores; i++) { + cluster.fork(); + } + + cluster.on("exit", (worker, code, signal) => { + console.log(`worker ${worker.process.pid} died, restart worker`); + cluster.fork(); + }); +} else { + var port = Number(process.env.PORT); + if (isNaN(port)) port = 1000; + + const server = new FosscordServer({ port }); + server.start().catch(console.error); + + // @ts-ignore + global.server = server; +} diff --git a/src/test/rethink_test.ts b/src/test/rethink_test.ts.disabled
index d1470515..d1470515 100644 --- a/src/test/rethink_test.ts +++ b/src/test/rethink_test.ts.disabled
diff --git a/src/test/test.ts b/src/test/test.ts
index eb0cb8b3..b7d877b3 100644 --- a/src/test/test.ts +++ b/src/test/test.ts
@@ -1,4 +1,4 @@ -import { getPermission } from "fosscord-server-util"; +import { getPermission } from "@fosscord/server-util"; async function main() { const t = await getPermission("811642917432066048", "812327318532915201"); diff --git a/src/util/Captcha.ts b/src/util/Captcha.ts
index e69de29b..cb0ff5c3 100644 --- a/src/util/Captcha.ts +++ b/src/util/Captcha.ts
@@ -0,0 +1 @@ +export {}; diff --git a/src/util/Config.ts b/src/util/Config.ts
index 60d83e1a..e500197f 100644 --- a/src/util/Config.ts +++ b/src/util/Config.ts
@@ -1,4 +1,4 @@ -import { Config, Snowflake } from "fosscord-server-util"; +import { Config, Snowflake } from "@fosscord/server-util"; import crypto from "crypto"; import fs from "fs"; @@ -16,7 +16,7 @@ export default { setAll: Config.setAll, }; -export interface RateLimit { +export interface RateLimitOptions { count: number; timespan: number; } @@ -62,8 +62,8 @@ export interface DefaultOptions { }; routes: { auth?: { - login?: RateLimit; - register?: RateLimit; + login?: RateLimitOptions; + register?: RateLimitOptions; }; channel?: {}; // TODO: rate limit configuration for all routes diff --git a/src/util/Event.ts b/src/util/Event.ts
index 8a24e4bb..5ff027e5 100644 --- a/src/util/Event.ts +++ b/src/util/Event.ts
@@ -1,4 +1,4 @@ -import { Event, EventModel } from "fosscord-server-util"; +import { Event, EventModel } from "@fosscord/server-util"; export async function emitEvent(payload: Omit<Event, "created_at">) { const obj = { diff --git a/src/util/Member.ts b/src/util/Member.ts
index 4d1b8ac5..2be9686e 100644 --- a/src/util/Member.ts +++ b/src/util/Member.ts
@@ -7,7 +7,7 @@ import { GuildModel, MemberModel, UserModel, -} from "fosscord-server-util"; +} from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; import Config from "./Config"; import { emitEvent } from "./Event"; diff --git a/src/util/User.ts b/src/util/User.ts
index 05213642..0f3768cc 100644 --- a/src/util/User.ts +++ b/src/util/User.ts
@@ -1,4 +1,4 @@ -import { toObject, UserModel } from "fosscord-server-util"; +import { toObject, UserModel } from "@fosscord/server-util"; import { HTTPError } from "lambert-server"; export const PublicUserProjection = { diff --git a/src/util/instanceOf.ts b/src/util/instanceOf.ts
index b4a231ba..e4e58092 100644 --- a/src/util/instanceOf.ts +++ b/src/util/instanceOf.ts
@@ -34,6 +34,9 @@ export function FieldErrors(fields: Record<string, { code?: string; message: str ); } +// TODO: implement Image data type: Data URI scheme that supports JPG, GIF, and PNG formats. An example Data URI format is: data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA +// Ensure you use the proper content type (image/jpeg, image/png, image/gif) that matches the image data being provided. + export class FieldError extends Error { constructor(public code: string | number, public message: string, public errors?: any) { super(message); diff --git a/tsconfig.json b/tsconfig.json
index 0976d3f7..1d4f4886 100644 --- a/tsconfig.json +++ b/tsconfig.json
@@ -1,5 +1,5 @@ { - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "src/test/rethink_test.ts.disabled"], "compilerOptions": { /* Visit https://aka.ms/tsconfig.json to read more about this file */