@@ -31,44 +28,31 @@ This repository will continue being as open-source while strictly following the
-# Contributing
+# How You Can Contribute
-All contributions are greatly appreciated, but I recommend creating an issue or replying in a comment to let me know what you are working on first that way we don't overwrite each other.
+Your input is invaluable! Before diving in, let's sync up to avoid overlapping efforts.
-Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on this project.
+## π Contribution Categories
-## Issues
+1. **Feature Requests/Enhancements**
+2. **Bug Reports**
+3. **Questions/Feedback**
-- Feature requests/enhancements
-- Bug reports
-- Questions/feedback
+## πΏ Branching Strategy
-## Branches
+- **production:** The live, running version. Please refrain from direct changes.
+- **staging:** All proposed changes go here. Submit a [pull request](https://help.github.com/en/articles/about-pull-requests) for review.
-- production -> don't touch, this is what's running in production
+## π Submitting Your Changes
-- staging -> [pull request][pr] this branch for everything
+1. **Fork** the repository on GitHub.
+2. **Clone** your forked repo locally.
+3. Make your changes and **commit** them.
+4. **Push** your changes back to your fork.
+5. When ready, create a [pull request](https://help.github.com/en/articles/about-pull-requests) for our review.
-## Pull Requests
-
-All pull requests are welcome!
-
-- [Fork][fork] the repository on GitHub.
-
-- [Clone][cloning] the forked repo to your local machine.
-
-- Do you changes
-
-- Commit your changes
-
-- Push your changes back up to your fork.
-
-- When you're ready, submit a [pull request][pr] so that we can review your changes.
-
-## Documentation
+---
-[DOCS.md](DOCS.md)
+Explore the [DOCS](DOCS.md) for detailed information.
-[fork]: https://help.github.com/en/articles/fork-a-repo
-[cloning]: https://help.github.com/en/articles/cloning-a-repository
-[pr]: https://help.github.com/en/articles/about-pull-requests
+Let's make Waifu.it even more fantastic together! π
diff --git a/config.js b/config.js
new file mode 100644
index 0000000..0d89fef
--- /dev/null
+++ b/config.js
@@ -0,0 +1,76 @@
+/**
+ * Configuration module for managing environment-specific settings.
+ * @module config
+ * @type {Object}
+ */
+
+import dotenv from 'dotenv';
+
+/**
+ * Loads environment variables from a .env file into process.env.
+ * @type {Function}
+ */
+dotenv.config();
+
+/**
+ * Application configuration settings.
+ * @type {Object}
+ * @property {string} database - Name of the database.
+ * @property {number} serverPort - Port for the server.
+ * @property {string} serverHost - Host for the server.
+ * @property {Object} roles - User roles.
+ * @property {string} roles.DEVELOPER - Developer role.
+ * @property {string} roles.ADMIN - Admin role.
+ * @property {string} roles.MOD - Moderator role.
+ * @property {string} roles.DB_MOD - Database Moderator role.
+ * @property {string} roles.PREMIUM - Premium role.
+ * @property {string} roles.USER - User role.
+ */
+const config = {
+ /**
+ * Name of the database.
+ * @type {string}
+ * @default 'mydatabase'
+ */
+ database: process.env.MONGODB_URI || 'mydatabase',
+
+ /**
+ * Port for the server.
+ * @type {number}
+ * @default 3000
+ */
+ serverPort: process.env.PORT || 3000,
+
+ /**
+ * Host for the server.
+ * @type {string}
+ * @default '127.0.0.1'
+ */
+ serverHost: process.env.HOST || 'http://localhost',
+
+ /**
+ * User roles.
+ * @type {Object}
+ * @property {string} DEVELOPER - Developer role.
+ * @property {string} ADMIN - Admin role.
+ * @property {string} MOD - Moderator role.
+ * @property {string} DB_MOD - Database Moderator role.
+ * @property {string} PREMIUM - Premium role.
+ * @property {string} USER - User role.
+ */
+ roles: {
+ DEVELOPER: 'developer',
+ ADMIN: 'admin',
+ MOD: 'moderator',
+ DB_MOD: 'database_moderator',
+ PREMIUM: 'premium',
+ USER: 'user',
+ },
+};
+
+/**
+ * Global configuration object based on the current environment.
+ * @global
+ * @type {Object}
+ */
+global.config = config;
diff --git a/nixpacks.toml b/nixpacks.toml
deleted file mode 100644
index ef582f8..0000000
--- a/nixpacks.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[phases.setup]
-nixPkgs = ['nodejs']
-
-[phases.install]
- cmd = "npm install --omit=dev"
-
-[start]
- cmd = "npm start"
-
diff --git a/package-lock.json b/package-lock.json
index fe7bb16..80a16f4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "waifu.it",
- "version": "3.4.14",
+ "version": "4.4.14",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "waifu.it",
- "version": "3.4.14",
+ "version": "4.4.14",
"license": "AGPLv3",
"dependencies": {
"chalk": "^4.1.2",
@@ -26,22 +26,36 @@
"ora": "^5.4.1",
"owoify-js": "^2.0.0",
"path": "^0.12.7",
- "request-ip": "^2.2.0",
+ "request-ip": "^3.3.0",
"winston": "^3.10.0",
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
- "nodemon": "^2.0.22",
+ "concurrently": "^8.2.0",
+ "nodemon": "^3.0.2",
"prettier": "^2.8.8"
},
"engines": {
"node": ">=18.x"
}
},
+ "node_modules/@babel/runtime": {
+ "version": "7.23.8",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.8.tgz",
+ "integrity": "sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw==",
+ "dev": true,
+ "dependencies": {
+ "regenerator-runtime": "^0.14.0"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@colors/colors": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
"integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==",
+ "optional": true,
"engines": {
"node": ">=0.1.90"
}
@@ -74,14 +88,17 @@
}
},
"node_modules/@types/node": {
- "version": "20.4.2",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.2.tgz",
- "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw=="
+ "version": "20.10.8",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.8.tgz",
+ "integrity": "sha512-f8nQs3cLxbAFc00vEU59yf9UyGUftkPaLGfvbVOIDdx2i1b8epBqj2aNGyP19fiyXWvlmZ7qC1XLjAzw/OKIeA==",
+ "dependencies": {
+ "undici-types": "~5.26.4"
+ }
},
"node_modules/@types/triple-beam": {
- "version": "1.3.2",
- "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.2.tgz",
- "integrity": "sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g=="
+ "version": "1.3.5",
+ "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
+ "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw=="
},
"node_modules/abbrev": {
"version": "1.1.1",
@@ -142,9 +159,9 @@
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/async": {
- "version": "3.2.4",
- "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
- "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
+ "version": "3.2.5",
+ "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz",
+ "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg=="
},
"node_modules/asynckit": {
"version": "0.4.0",
@@ -299,12 +316,13 @@
}
},
"node_modules/call-bind": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
- "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz",
+ "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==",
"dependencies": {
- "function-bind": "^1.1.1",
- "get-intrinsic": "^1.0.2"
+ "function-bind": "^1.1.2",
+ "get-intrinsic": "^1.2.1",
+ "set-function-length": "^1.1.1"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -364,9 +382,9 @@
}
},
"node_modules/cli-spinners": {
- "version": "2.9.0",
- "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.0.tgz",
- "integrity": "sha512-4/aL9X3Wh0yiMQlE+eeRhWP6vclO3QRtw1JHKIT0FFUs5FjpFmESqtMvYZ0+lbzBw900b95mS0hohy+qn2VK/g==",
+ "version": "2.9.2",
+ "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz",
+ "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==",
"engines": {
"node": ">=6"
},
@@ -388,6 +406,20 @@
"@colors/colors": "1.5.0"
}
},
+ "node_modules/cliui": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
+ "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
+ "dev": true,
+ "dependencies": {
+ "string-width": "^4.2.0",
+ "strip-ansi": "^6.0.1",
+ "wrap-ansi": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/clone": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz",
@@ -469,6 +501,48 @@
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true
},
+ "node_modules/concurrently": {
+ "version": "8.2.2",
+ "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz",
+ "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==",
+ "dev": true,
+ "dependencies": {
+ "chalk": "^4.1.2",
+ "date-fns": "^2.30.0",
+ "lodash": "^4.17.21",
+ "rxjs": "^7.8.1",
+ "shell-quote": "^1.8.1",
+ "spawn-command": "0.0.2",
+ "supports-color": "^8.1.1",
+ "tree-kill": "^1.2.2",
+ "yargs": "^17.7.2"
+ },
+ "bin": {
+ "conc": "dist/bin/concurrently.js",
+ "concurrently": "dist/bin/concurrently.js"
+ },
+ "engines": {
+ "node": "^14.13.0 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
+ }
+ },
+ "node_modules/concurrently/node_modules/supports-color": {
+ "version": "8.1.1",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
+ "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
+ "dev": true,
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/supports-color?sponsor=1"
+ }
+ },
"node_modules/content-disposition": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
@@ -518,6 +592,22 @@
"node": ">= 0.10"
}
},
+ "node_modules/date-fns": {
+ "version": "2.30.0",
+ "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",
+ "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",
+ "dev": true,
+ "dependencies": {
+ "@babel/runtime": "^7.21.0"
+ },
+ "engines": {
+ "node": ">=0.11"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/date-fns"
+ }
+ },
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -537,6 +627,19 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/define-data-property": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz",
+ "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==",
+ "dependencies": {
+ "get-intrinsic": "^1.2.1",
+ "gopd": "^1.0.1",
+ "has-property-descriptors": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@@ -610,6 +713,15 @@
"node": ">= 0.8"
}
},
+ "node_modules/escalade": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
+ "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
+ "dev": true,
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
@@ -840,9 +952,9 @@
}
},
"node_modules/fsevents": {
- "version": "2.3.2",
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
- "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"optional": true,
@@ -854,24 +966,36 @@
}
},
"node_modules/function-bind": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
- "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
},
"node_modules/generate-password": {
- "version": "1.7.0",
- "resolved": "https://registry.npmjs.org/generate-password/-/generate-password-1.7.0.tgz",
- "integrity": "sha512-WPCtlfy0jexf7W5IbwxGUgpIDvsZIohbI2DAq2Q6TSlKKis+G4GT9sxvPxrZUGL8kP6WUXMWNqYnxY6DDKAdFA=="
+ "version": "1.7.1",
+ "resolved": "https://registry.npmjs.org/generate-password/-/generate-password-1.7.1.tgz",
+ "integrity": "sha512-9bVYY+16m7W7GczRBDqXE+VVuCX+bWNrfYKC/2p2JkZukFb2sKxT6E3zZ3mJGz7GMe5iRK0A/WawSL3jQfJuNQ=="
+ },
+ "node_modules/get-caller-file": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+ "dev": true,
+ "engines": {
+ "node": "6.* || 8.* || >= 10.*"
+ }
},
"node_modules/get-intrinsic": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
- "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz",
+ "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==",
"dependencies": {
- "function-bind": "^1.1.1",
- "has": "^1.0.3",
+ "function-bind": "^1.1.2",
"has-proto": "^1.0.1",
- "has-symbols": "^1.0.3"
+ "has-symbols": "^1.0.3",
+ "hasown": "^2.0.0"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -889,15 +1013,15 @@
"node": ">= 6"
}
},
- "node_modules/has": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
- "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "node_modules/gopd": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
+ "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
"dependencies": {
- "function-bind": "^1.1.1"
+ "get-intrinsic": "^1.1.3"
},
- "engines": {
- "node": ">= 0.4.0"
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-flag": {
@@ -908,6 +1032,17 @@
"node": ">=8"
}
},
+ "node_modules/has-property-descriptors": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz",
+ "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==",
+ "dependencies": {
+ "get-intrinsic": "^1.2.2"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/has-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
@@ -930,6 +1065,17 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/hasown": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz",
+ "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/http-errors": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
@@ -1010,11 +1156,6 @@
"node": ">= 0.10"
}
},
- "node_modules/is_js": {
- "version": "0.9.0",
- "resolved": "https://registry.npmjs.org/is_js/-/is_js-0.9.0.tgz",
- "integrity": "sha512-8Y5EHSH+TonfUHX2g3pMJljdbGavg55q4jmHzghJCdqYDbdNROC8uw/YFQwIRCRqRJT1EY3pJefz+kglw+o7sg=="
- },
"node_modules/is-arrayish": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
@@ -1136,16 +1277,27 @@
}
},
"node_modules/logform": {
- "version": "2.5.1",
- "resolved": "https://registry.npmjs.org/logform/-/logform-2.5.1.tgz",
- "integrity": "sha512-9FyqAm9o9NKKfiAKfZoYo9bGXXuwMkxQiQttkT4YjjVtQVIQtK6LmVtlxmCaFswo6N4AfEkHqZTV0taDtPotNg==",
+ "version": "2.6.0",
+ "resolved": "https://registry.npmjs.org/logform/-/logform-2.6.0.tgz",
+ "integrity": "sha512-1ulHeNPp6k/LD8H91o7VYFBng5i1BDE7HoKxVbZiGFidS1Rj65qcywLxX+pVfAPoQJEjRdvKcusKwOupHCVOVQ==",
"dependencies": {
- "@colors/colors": "1.5.0",
+ "@colors/colors": "1.6.0",
"@types/triple-beam": "^1.3.2",
"fecha": "^4.2.0",
"ms": "^2.1.1",
"safe-stable-stringify": "^2.3.1",
"triple-beam": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 12.0.0"
+ }
+ },
+ "node_modules/logform/node_modules/@colors/colors": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz",
+ "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==",
+ "engines": {
+ "node": ">=0.1.90"
}
},
"node_modules/logform/node_modules/ms": {
@@ -1153,6 +1305,18 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
+ "node_modules/lru-cache": {
+ "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"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -1231,9 +1395,9 @@
}
},
"node_modules/moment": {
- "version": "2.29.4",
- "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
- "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
+ "version": "2.30.1",
+ "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
+ "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"engines": {
"node": "*"
}
@@ -1277,9 +1441,9 @@
}
},
"node_modules/mongoose": {
- "version": "5.13.20",
- "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.20.tgz",
- "integrity": "sha512-TjGFa/XnJYt+wLmn8y9ssjyO2OhBMeEBtOHb9iJM16EWu2Du6L1Q6zSiEK2ziyYQM8agb4tumNIQFzqbxId7MA==",
+ "version": "5.13.22",
+ "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.22.tgz",
+ "integrity": "sha512-p51k/c4X/MfqeQ3I1ranlDiggLzNumZrTDD9CeezHwZxt2/btf+YZD7MCe07RAY2NgFYVMayq6jMamw02Jmf9w==",
"dependencies": {
"@types/bson": "1.x || 4.0.x",
"@types/mongodb": "^3.5.27",
@@ -1375,9 +1539,9 @@
}
},
"node_modules/node-fetch": {
- "version": "2.6.12",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
- "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
+ "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
@@ -1394,18 +1558,18 @@
}
},
"node_modules/nodemon": {
- "version": "2.0.22",
- "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz",
- "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==",
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.2.tgz",
+ "integrity": "sha512-9qIN2LNTrEzpOPBaWHTm4Asy1LxXLSickZStAQ4IZe7zsoIpD/A7LWxhZV3t4Zu352uBcqVnRsDXSMR2Sc3lTA==",
"dev": true,
"dependencies": {
"chokidar": "^3.5.2",
- "debug": "^3.2.7",
+ "debug": "^4",
"ignore-by-default": "^1.0.1",
"minimatch": "^3.1.2",
"pstree.remy": "^1.1.8",
- "semver": "^5.7.1",
- "simple-update-notifier": "^1.0.7",
+ "semver": "^7.5.3",
+ "simple-update-notifier": "^2.0.0",
"supports-color": "^5.5.0",
"touch": "^3.1.0",
"undefsafe": "^2.0.5"
@@ -1414,7 +1578,7 @@
"nodemon": "bin/nodemon.js"
},
"engines": {
- "node": ">=8.10.0"
+ "node": ">=10"
},
"funding": {
"type": "opencollective",
@@ -1422,12 +1586,20 @@
}
},
"node_modules/nodemon/node_modules/debug": {
- "version": "3.2.7",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
- "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"dev": true,
"dependencies": {
- "ms": "^2.1.1"
+ "ms": "2.1.2"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
}
},
"node_modules/nodemon/node_modules/has-flag": {
@@ -1440,9 +1612,9 @@
}
},
"node_modules/nodemon/node_modules/ms": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
- "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"node_modules/nodemon/node_modules/supports-color": {
@@ -1498,9 +1670,9 @@
}
},
"node_modules/object-inspect": {
- "version": "1.12.3",
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
- "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
+ "version": "1.13.1",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
+ "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@@ -1761,18 +1933,21 @@
"node": ">=8.10.0"
}
},
+ "node_modules/regenerator-runtime": {
+ "version": "0.14.1",
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
+ "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==",
+ "dev": true
+ },
"node_modules/regexp-clone": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz",
"integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw=="
},
"node_modules/request-ip": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/request-ip/-/request-ip-2.2.0.tgz",
- "integrity": "sha512-Hn4zUAr+XHbUs2RrfHur62t7+UhvtevqK32ordFewguEfNHUkhSdYgbG7PDGmXZEzqEXll9bei0+VMe6gkmuUQ==",
- "dependencies": {
- "is_js": "^0.9.0"
- }
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/request-ip/-/request-ip-3.3.0.tgz",
+ "integrity": "sha512-cA6Xh6e0fDBBBwH77SLJaJPBmD3nWVAcF9/XAcsrIHdjhFzFiB5aNQFytdjCGPezU3ROwrR11IddKAM08vohxA=="
},
"node_modules/require-at": {
"version": "1.0.6",
@@ -1782,6 +1957,15 @@
"node": ">=4"
}
},
+ "node_modules/require-directory": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/restore-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz",
@@ -1794,6 +1978,15 @@
"node": ">=8"
}
},
+ "node_modules/rxjs": {
+ "version": "7.8.1",
+ "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz",
+ "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==",
+ "dev": true,
+ "dependencies": {
+ "tslib": "^2.1.0"
+ }
+ },
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -1839,12 +2032,18 @@
}
},
"node_modules/semver": {
- "version": "5.7.2",
- "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
- "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
+ "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
+ "dependencies": {
+ "lru-cache": "^6.0.0"
+ },
"bin": {
- "semver": "bin/semver"
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
}
},
"node_modules/send": {
@@ -1904,11 +2103,34 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/set-function-length": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz",
+ "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==",
+ "dependencies": {
+ "define-data-property": "^1.1.1",
+ "get-intrinsic": "^1.2.1",
+ "gopd": "^1.0.1",
+ "has-property-descriptors": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
+ "node_modules/shell-quote": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz",
+ "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==",
+ "dev": true,
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@@ -1941,24 +2163,15 @@
}
},
"node_modules/simple-update-notifier": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz",
- "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
+ "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
"dev": true,
"dependencies": {
- "semver": "~7.0.0"
+ "semver": "^7.5.3"
},
"engines": {
- "node": ">=8.10.0"
- }
- },
- "node_modules/simple-update-notifier/node_modules/semver": {
- "version": "7.0.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz",
- "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==",
- "dev": true,
- "bin": {
- "semver": "bin/semver.js"
+ "node": ">=10"
}
},
"node_modules/sliced": {
@@ -1975,6 +2188,12 @@
"memory-pager": "^1.0.2"
}
},
+ "node_modules/spawn-command": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz",
+ "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==",
+ "dev": true
+ },
"node_modules/stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
@@ -2081,6 +2300,15 @@
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
+ "node_modules/tree-kill": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
+ "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
+ "dev": true,
+ "bin": {
+ "tree-kill": "cli.js"
+ }
+ },
"node_modules/triple-beam": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz",
@@ -2089,6 +2317,12 @@
"node": ">= 14.0.0"
}
},
+ "node_modules/tslib": {
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
+ "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
+ "dev": true
+ },
"node_modules/type-is": {
"version": "1.6.18",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
@@ -2107,6 +2341,11 @@
"integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
"dev": true
},
+ "node_modules/undici-types": {
+ "version": "5.26.5",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
+ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
+ },
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -2172,11 +2411,11 @@
}
},
"node_modules/winston": {
- "version": "3.10.0",
- "resolved": "https://registry.npmjs.org/winston/-/winston-3.10.0.tgz",
- "integrity": "sha512-nT6SIDaE9B7ZRO0u3UvdrimG0HkB7dSTAgInQnNR2SOPJ4bvq5q79+pXLftKmP52lJGW15+H5MCK0nM9D3KB/g==",
+ "version": "3.11.0",
+ "resolved": "https://registry.npmjs.org/winston/-/winston-3.11.0.tgz",
+ "integrity": "sha512-L3yR6/MzZAOl0DsysUXHVjOwv8mKZ71TrA/41EIduGpOOV5LQVodqN+QdQ6BS6PJ/RdIshZhq84P/fStEZkk7g==",
"dependencies": {
- "@colors/colors": "1.5.0",
+ "@colors/colors": "^1.6.0",
"@dabh/diagnostics": "^2.0.2",
"async": "^3.2.3",
"is-stream": "^2.0.0",
@@ -2210,16 +2449,16 @@
}
},
"node_modules/winston-transport": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz",
- "integrity": "sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q==",
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.6.0.tgz",
+ "integrity": "sha512-wbBA9PbPAHxKiygo7ub7BYRiKxms0tpfU2ljtWzb3SjRjv5yl6Ozuy/TkXf00HTAt+Uylo3gSkNwzc4ME0wiIg==",
"dependencies": {
"logform": "^2.3.2",
"readable-stream": "^3.6.0",
"triple-beam": "^1.3.0"
},
"engines": {
- "node": ">= 6.4.0"
+ "node": ">= 12.0.0"
}
},
"node_modules/winston-transport/node_modules/readable-stream": {
@@ -2235,6 +2474,14 @@
"node": ">= 6"
}
},
+ "node_modules/winston/node_modules/@colors/colors": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz",
+ "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==",
+ "engines": {
+ "node": ">=0.1.90"
+ }
+ },
"node_modules/winston/node_modules/readable-stream": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
@@ -2247,6 +2494,65 @@
"engines": {
"node": ">= 6"
}
+ },
+ "node_modules/wrap-ansi": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
+ "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
+ "dev": true,
+ "dependencies": {
+ "ansi-styles": "^4.0.0",
+ "string-width": "^4.1.0",
+ "strip-ansi": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/wrap-ansi?sponsor=1"
+ }
+ },
+ "node_modules/y18n": {
+ "version": "5.0.8",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
+ "dev": true,
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/yallist": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
+ "dev": true
+ },
+ "node_modules/yargs": {
+ "version": "17.7.2",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
+ "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
+ "dev": true,
+ "dependencies": {
+ "cliui": "^8.0.1",
+ "escalade": "^3.1.1",
+ "get-caller-file": "^2.0.5",
+ "require-directory": "^2.1.1",
+ "string-width": "^4.2.3",
+ "y18n": "^5.0.5",
+ "yargs-parser": "^21.1.1"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/yargs-parser": {
+ "version": "21.1.1",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
+ "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
+ "dev": true,
+ "engines": {
+ "node": ">=12"
+ }
}
}
}
diff --git a/package.json b/package.json
index 305f3b9..0cdba54 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "waifu.it",
- "version": "3.4.14",
+ "version": "4.4.14",
"description": "Random API Serving Anime stuff",
"author": "Aeryk",
"private": true,
@@ -9,6 +9,7 @@
"engines": {
"node": ">=18.x"
},
+ "type": "module",
"scripts": {
"start": "node src/index.js",
"dev": "nodemon src/index.js"
@@ -31,12 +32,13 @@
"ora": "^5.4.1",
"owoify-js": "^2.0.0",
"path": "^0.12.7",
- "request-ip": "^2.2.0",
+ "request-ip": "^3.3.0",
"winston": "^3.10.0",
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
- "nodemon": "^2.0.22",
+ "concurrently": "^8.2.0",
+ "nodemon": "^3.0.2",
"prettier": "^2.8.8"
},
"keywords": [
diff --git a/src/app.js b/src/app.js
index ee17c3c..e14f801 100644
--- a/src/app.js
+++ b/src/app.js
@@ -1,32 +1,90 @@
-const express = require('express')
-const cors = require('cors')
-// const winston = require('winston')
-// const expressWinston = require('express-winston')
-// const requestIp = require('request-ip');
-const routes = require('./routes')
-const {
- handler404,
- errorsLogger,
- errorsHandler,
-} = require('./handlers/errors/index')
-require('winston-daily-rotate-file')
-const { ipLogger } = require('./handlers/logger/ip')
-const path = require('path')
-
-// Express APP
-const app = express()
-app.use(cors())
-app.set('trust proxy', 1)
-
-// Logger
+/*** Importing necessary modules ***/
+import express from 'express';
+import bodyParser from 'body-parser';
+import cors from 'cors';
+import pkg from '../package.json' assert { type: 'json' };
+/*** Importing custom error handlers and logger middleware ***/
+import {
+ handle404 /*** @params: req, res, next ***/,
+ logErrors /*** @params: err, req, res, next ***/,
+ errorHandler /*** @params: err, req, res, next ***/,
+} from './middlewares/errors.js';
+import { logIP } from './middlewares/logger.js';
+import routesV3 from './routes/v3/index.js';
+import routesV4 from './routes/v4/index.js';
+
+/*** Creating an instance of Express ***/
+const app = express();
+
+/*** Enabling CORS for all routes ***/
+app.use(cors());
+
+/*** Trusting the first proxy (when running behind a reverse proxy like Nginx) ***/
+app.set('trust proxy', 1);
+
+/*** Middleware to parse JSON-encoded bodies ***/
+app.use(express.json());
+
+/*** Middleware to parse URL-encoded bodies ***/
+app.use(express.urlencoded({ extended: true }));
+
+/*** Logger middleware ***/
+/**
+ * @middleware
+ * @description Enables IP logging for incoming requests.
+ * @function
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
if (process.env.LOGGER === 'true') {
- app.use(ipLogger)
+ app.use(logIP);
}
-// Main website (waifu.it)
-app.use('/', express.static(path.join(__dirname, 'frontend')))
+/*** Middleware to parse the request body ***/
+app.use(bodyParser.json());
+
+/*** Custom API routes ***/
+/**
+ * Route: GET /api/v3
+ * @returns {void}
+ */
+app.use(routesV3);
+/**
+ * Route: GET /api/v4
+ * Description: Endpoint to verify the basic functionality of the API. Returns a success message if the API is working as expected.
+ * @name VerifyAPI
+ * @function
+ * @memberof routes
+ * @inner
+ * @param {express.Request} req - Express request object.
+ * @param {express.Response} res - Express response object.
+ * @returns {void}
+ */
+app.get('/api/v4', (req, res) => {
+ res.status(200).json({
+ version: pkg.version,
+ message: 'API is functioning correctly.',
+ });
+});
+app.use('/api/v4', routesV4);
-app.use(routes)
-app.use(handler404, errorsLogger, errorsHandler)
+/**
+ * @apiMiddleware
+ * @function
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ *
+ * @apiSuccess {Object[]} response - Response data.
+ *
+ * @apiError {BadRequest} BadRequest - Invalid request parameters.
+ * @apiError {Unauthorized} Unauthorized - Only authenticated users can access the data.
+ * @apiError {Forbidden} Forbidden - Only authorized users can access the data.
+ * @apiError {NotFound} NotFound - The requested resource was not found.
+ * @apiError {InternalServerError} InternalServerError - Something went wrong on the server.
+ */
+app.use(handle404, logErrors, errorHandler);
-module.exports = app
+/*** Exporting the Express app instance ***/
+export default app;
diff --git a/src/controllers/facts/randomFacts.js b/src/controllers/facts/randomFacts.js
deleted file mode 100644
index 9cbb4d8..0000000
--- a/src/controllers/facts/randomFacts.js
+++ /dev/null
@@ -1,44 +0,0 @@
-const createError = require('http-errors')
-const Facts = require('../../models/schemas/Facts')
-const tagsFilter = require('../../utils/tagsFilter')
-const lengthFilter = require('../../utils/lengthFilter')
-const Stats = require('../../models/schemas/Stat')
-
-// Get random Anime Fact
-module.exports = async function getRandomFact(req, res, next) {
- try {
- const { minLength, maxLength, tags } = req.query
-
- const filter = {}
-
- if (minLength || maxLength) {
- filter.length = lengthFilter(minLength, maxLength)
- }
-
- if (tags) {
- filter.tags = tagsFilter(tags)
- }
-
- const [result] = await Facts.aggregate([
- // Apply filters (if any)
- { $match: filter },
- // Select a random document from the results
- { $sample: { size: 1 } },
- { $project: { __v: 0 } },
- ])
-
- if (!result) {
- return next(createError(404, 'Could not find any matching fact'))
- }
-
- res.status(200).json(result)
-
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { facts: 1 } })
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
diff --git a/src/controllers/gifs/randomMidfing.js b/src/controllers/gifs/randomMidfing.js
deleted file mode 100644
index b1bb31c..0000000
--- a/src/controllers/gifs/randomMidfing.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const createError = require('http-errors')
-const Midfinger = require('../../models/schemas/Midfing')
-const Stats = require('../../models/schemas/Stat')
-
-// Get random Anime Midfinger
-module.exports = async function getRandomMidfinger(req, res, next) {
- try {
- const [result] = await Midfinger.aggregate([
- // Select a random document from the results
- { $sample: { size: 1 } },
- { $project: { __v: 0, _id: 0 } },
- ])
-
- if (!result) {
- return next(createError(404, 'Could not find any Midfinger Gif'))
- }
-
- res.status(200).json(result)
-
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { midfing: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
diff --git a/src/controllers/gifs/randomNervous.js b/src/controllers/gifs/randomNervous.js
deleted file mode 100644
index a33acef..0000000
--- a/src/controllers/gifs/randomNervous.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const createError = require('http-errors')
-const Nervouse = require('../../models/schemas/Nervouse')
-const Stats = require('../../models/schemas/Stat')
-
-// Get random Anime Nervous
-module.exports = async function getRandomNervous(req, res, next) {
- try {
- const [result] = await Nervouse.aggregate([
- // Select a random document from the results
- { $sample: { size: 1 } },
- { $project: { __v: 0, _id: 0 } },
- ])
-
- if (!result) {
- return next(createError(404, 'Could not find any Nervous Gif'))
- }
-
- res.status(200).json(result)
-
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { nervous: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
diff --git a/src/controllers/quotes/randomQuotes.js b/src/controllers/quotes/randomQuotes.js
deleted file mode 100644
index 455dbcf..0000000
--- a/src/controllers/quotes/randomQuotes.js
+++ /dev/null
@@ -1,41 +0,0 @@
-const createError = require('http-errors')
-const Quotes = require('../../models/schemas/Quotes')
-const Stats = require('../../models/schemas/Stat')
-
-// Get random Anime Quote
-module.exports = async function getRandomQuote(req, res, next) {
- try {
- const { character } = req.query
-
- const filter = {}
-
- if (character) {
- filter.author = character
- }
-
- const [result] = await Quotes.aggregate([
- // Apply filters (if any)
- { $match: filter },
- // Select a random document from the results
- { $sample: { size: 1 } },
- { $project: { __v: 0 } },
- ])
-
- if (!result) {
- return next(createError(404, 'Could not find any matching Quote'))
- }
-
- res.status(200).json(result)
-
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { quotes: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
diff --git a/src/controllers/utils/listTags.js b/src/controllers/utils/listTags.js
deleted file mode 100644
index 21334ec..0000000
--- a/src/controllers/utils/listTags.js
+++ /dev/null
@@ -1,43 +0,0 @@
-const Tags = require('../../models/schemas/Tags')
-const parseOrder = require('../../utils/parseOrder')
-const Stats = require('../../models/schemas/Stat')
-
-module.exports = async function listTags(req, res, next) {
- try {
- let { sortBy, sortOrder } = req.query
-
- // Supported parameter values
- const Values = { sortBy: ['name', 'usedCount'] }
- // The default sort order depends on the `sortBy` field
- const defaultSortOrder = { name: 1, usedCount: -1 }
-
- sortBy = Values.sortBy.includes(sortBy) ? sortBy : 'name'
- sortOrder = parseOrder(sortOrder) || defaultSortOrder[sortBy] || 1
-
- const results = await Tags.aggregate([
- {
- $lookup: {
- from: 'facts',
- localField: 'name',
- foreignField: 'tags',
- as: 'usedCount',
- },
- },
- { $addFields: { usedCount: { $size: '$usedCount' } } },
- { $sort: { [sortBy]: sortOrder } },
- { $project: { __v: 0 } },
- ])
- res.json(results)
-
- await Stats.findOneAndUpdate (
- { _id: "systemstats" },
- { $inc: { tags: 1 } },
- )
- } catch (error) {
- await Stats.findOneAndUpdate (
- { _id: "systemstats" },
- { $inc: { failed_requests: 1 } },
- )
- return next(error)
- }
-}
diff --git a/src/controllers/utils/owoify.js b/src/controllers/utils/owoify.js
deleted file mode 100644
index 276629b..0000000
--- a/src/controllers/utils/owoify.js
+++ /dev/null
@@ -1,27 +0,0 @@
-const createError = require('http-errors')
-const owoify = require('owoify-js').default
-const Stats = require('../../models/schemas/Stat')
-
-module.exports = async function getOwofiyText(req, res, next) {
- try {
- const { text } = req.query
-
- if (!text) {
- return next(createError(404, 'Invalid text input.'))
- }
- res.status(200).json({
- text: owoify(text),
- })
-
- return await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { owoify: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
diff --git a/src/controllers/utils/randomPassword.js b/src/controllers/utils/randomPassword.js
deleted file mode 100644
index c312187..0000000
--- a/src/controllers/utils/randomPassword.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const pass = require('generate-password')
-const Stats = require('../../models/schemas/Stat')
-
-// Get random Password
-module.exports = async function getRandomPassword(req, res, next) {
- try {
- const { charLength } = req.query
-
- const password = pass.generate({
- length: charLength || 50,
- uppercase: true,
- numbers: true,
- symbols: true,
- lowercase: true,
- strict: true,
- })
-
- res.status(200).json({
- pass: password,
- })
-
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { password: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
diff --git a/src/controllers/utils/uvuify.js b/src/controllers/utils/uvuify.js
deleted file mode 100644
index 2245ac8..0000000
--- a/src/controllers/utils/uvuify.js
+++ /dev/null
@@ -1,27 +0,0 @@
-const createError = require('http-errors')
-const uwuify = require('owoify-js')
-const Stats = require('../../models/schemas/Stat')
-
-module.exports = async function getOwofiyText(req, res, next) {
- try {
- const { text } = req.query
-
- if (!text) {
- return next(createError(404, 'Invalid text input.'))
- }
- res.status(200).json({
- text: uwuify(text),
- })
-
- return await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { uwuify: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
\ No newline at end of file
diff --git a/src/controllers/utils/uwuify.js b/src/controllers/utils/uwuify.js
deleted file mode 100644
index 9e5f9e2..0000000
--- a/src/controllers/utils/uwuify.js
+++ /dev/null
@@ -1,27 +0,0 @@
-const createError = require('http-errors')
-const uvuify = require('owoify-js')
-const Stats = require('../../models/schemas/Stat')
-
-module.exports = async function getOwofiyText(req, res, next) {
- try {
- const { text } = req.query
-
- if (!text) {
- return next(createError(404, 'Invalid text input.'))
- }
- res.status(200).json({
- text: uvuify(text),
- })
-
- return await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { uvuify: 1 } }
- )
- } catch (error) {
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { failed_requests: 1 } }
- )
- return next(error)
- }
-}
\ No newline at end of file
diff --git a/src/controllers/v3/facts/randomFacts.js b/src/controllers/v3/facts/randomFacts.js
new file mode 100644
index 0000000..b64a767
--- /dev/null
+++ b/src/controllers/v3/facts/randomFacts.js
@@ -0,0 +1,58 @@
+import createError from 'http-errors';
+import Facts from '../../../models/schemas/Fact.js';
+import tagsFilter from '../../../modules/tagsFilter.js';
+import lengthFilter from '../../../modules/lengthFilter.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Gets a random anime fact with optional length and tags filters and updates system statistics.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const getRandomFact = async (req, res, next) => {
+ try {
+ const { minLength, maxLength, tags } = req.query;
+
+ // Create a filter object based on the optional length and tags parameters
+ const filter = {};
+
+ // Apply length filter (if minLength or maxLength is provided)
+ if (minLength || maxLength) {
+ filter.length = lengthFilter(minLength, maxLength);
+ }
+
+ // Apply tags filter (if tags are provided)
+ if (tags) {
+ filter.tags = tagsFilter(tags);
+ }
+
+ // Aggregate to match the filter, select a random fact, and project excluding version field
+ const [result] = await Facts.aggregate([
+ { $match: filter }, // Apply filters (if any)
+ { $sample: { size: 1 } }, // Select a random document from the results
+ { $project: { __v: 0 } },
+ ]);
+
+ // If no fact is found, return a 404 error
+ if (!result) {
+ return next(createError(404, 'Could not find any matching fact'));
+ }
+
+ // Respond with the random fact
+ res.status(200).json(result);
+
+ // Update system statistics for facts
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { facts: 1 } });
+ } catch (error) {
+ // Update system statistics for failed requests
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomFact;
\ No newline at end of file
diff --git a/src/controllers/gifs/randomAngry.js b/src/controllers/v3/gifs/randomAngry.js
similarity index 59%
rename from src/controllers/gifs/randomAngry.js
rename to src/controllers/v3/gifs/randomAngry.js
index c336680..6156cb9 100644
--- a/src/controllers/gifs/randomAngry.js
+++ b/src/controllers/v3/gifs/randomAngry.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Angry = require('../../models/schemas/Angry')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Angry from '../../../models/schemas/Angry.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Angry
-module.exports = async function getRandomAngry(req, res, next) {
+const getRandomAngry = async (req, res, next) => {
try {
const [result] = await Angry.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Angry Gif'))
+ return next(createError(404, 'Could not find any Angry Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { angry: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { angry: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomAngry;
diff --git a/src/controllers/gifs/randomBaka.js b/src/controllers/v3/gifs/randomBaka.js
similarity index 59%
rename from src/controllers/gifs/randomBaka.js
rename to src/controllers/v3/gifs/randomBaka.js
index f04d74a..746b3b6 100644
--- a/src/controllers/gifs/randomBaka.js
+++ b/src/controllers/v3/gifs/randomBaka.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Baka = require('../../models/schemas/Baka')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Baka from '../../../models/schemas/Baka.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Baka
-module.exports = async function getRandomBaka(req, res, next) {
+const getRandomBaka = async (req, res, next) => {
try {
const [result] = await Baka.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Baka Gif'))
+ return next(createError(404, 'Could not find any Baka Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { baka: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { baka: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBaka;
diff --git a/src/controllers/gifs/randomBite.js b/src/controllers/v3/gifs/randomBite.js
similarity index 59%
rename from src/controllers/gifs/randomBite.js
rename to src/controllers/v3/gifs/randomBite.js
index d2aad16..ddf9bf1 100644
--- a/src/controllers/gifs/randomBite.js
+++ b/src/controllers/v3/gifs/randomBite.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Bite = require('../../models/schemas/Bite')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Bite from '../../../models/schemas/Bite.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Bite
-module.exports = async function getRandomBite(req, res, next) {
+const getRandomBite = async (req, res, next) => {
try {
const [result] = await Bite.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Bite Gif'))
+ return next(createError(404, 'Could not find any Bite Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bite: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bite: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBite;
diff --git a/src/controllers/gifs/randomBlush.js b/src/controllers/v3/gifs/randomBlush.js
similarity index 59%
rename from src/controllers/gifs/randomBlush.js
rename to src/controllers/v3/gifs/randomBlush.js
index 924f942..1a90820 100644
--- a/src/controllers/gifs/randomBlush.js
+++ b/src/controllers/v3/gifs/randomBlush.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Blush = require('../../models/schemas/Blush')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Blush from '../../../models/schemas/Blush.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Blush
-module.exports = async function getRandomBlush(req, res, next) {
+const getRandomBlush = async (req, res, next) => {
try {
const [result] = await Blush.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Blush Gif'))
+ return next(createError(404, 'Could not find any Blush Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { blush: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { blush: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBlush;
diff --git a/src/controllers/gifs/randomBonk.js b/src/controllers/v3/gifs/randomBonk.js
similarity index 59%
rename from src/controllers/gifs/randomBonk.js
rename to src/controllers/v3/gifs/randomBonk.js
index 003328f..c559823 100644
--- a/src/controllers/gifs/randomBonk.js
+++ b/src/controllers/v3/gifs/randomBonk.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Bonk = require('../../models/schemas/Bonk')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Bonk from '../../../models/schemas/Bonk.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Bonk
-module.exports = async function getRandomBonk(req, res, next) {
+const getRandomBonk = async (req, res, next) => {
try {
const [result] = await Bonk.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Bonk Gif'))
+ return next(createError(404, 'Could not find any Bonk Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bonk: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bonk: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBonk;
diff --git a/src/controllers/gifs/randomBored.js b/src/controllers/v3/gifs/randomBored.js
similarity index 59%
rename from src/controllers/gifs/randomBored.js
rename to src/controllers/v3/gifs/randomBored.js
index a1d8b31..2caedfb 100644
--- a/src/controllers/gifs/randomBored.js
+++ b/src/controllers/v3/gifs/randomBored.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Bored = require('../../models/schemas/Bored')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Bored from '../../../models/schemas/Bored.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Bored
-module.exports = async function getRandomBored(req, res, next) {
+const getRandomBored = async (req, res, next) => {
try {
const [result] = await Bored.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Bored Gif'))
+ return next(createError(404, 'Could not find any Bored Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bored: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bored: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBored;
diff --git a/src/controllers/gifs/randomBully.js b/src/controllers/v3/gifs/randomBully.js
similarity index 59%
rename from src/controllers/gifs/randomBully.js
rename to src/controllers/v3/gifs/randomBully.js
index 3e70dc1..ede6578 100644
--- a/src/controllers/gifs/randomBully.js
+++ b/src/controllers/v3/gifs/randomBully.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Bully = require('../../models/schemas/Bully')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Bully from '../../../models/schemas/Bully.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Bully
-module.exports = async function getRandomBully(req, res, next) {
+const getRandomBully = async (req, res, next) => {
try {
const [result] = await Bully.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Bully Gif'))
+ return next(createError(404, 'Could not find any Bully Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bully: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bully: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBully;
diff --git a/src/controllers/gifs/randomBye.js b/src/controllers/v3/gifs/randomBye.js
similarity index 60%
rename from src/controllers/gifs/randomBye.js
rename to src/controllers/v3/gifs/randomBye.js
index 2cb2dd7..873468b 100644
--- a/src/controllers/gifs/randomBye.js
+++ b/src/controllers/v3/gifs/randomBye.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Bye = require('../../models/schemas/Bye')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Bye from '../../../models/schemas/Bye.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Bye
-module.exports = async function getRandomBye(req, res, next) {
+const getRandomBye = async (req, res, next) => {
try {
const [result] = await Bye.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Bye Gif'))
+ return next(createError(404, 'Could not find any Bye Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bye: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bye: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomBye;
diff --git a/src/controllers/gifs/randomChase.js b/src/controllers/v3/gifs/randomChase.js
similarity index 59%
rename from src/controllers/gifs/randomChase.js
rename to src/controllers/v3/gifs/randomChase.js
index 661e16f..a16f38b 100644
--- a/src/controllers/gifs/randomChase.js
+++ b/src/controllers/v3/gifs/randomChase.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Chase = require('../../models/schemas/Chase')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Chase from '../../../models/schemas/Chase.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Chase
-module.exports = async function getRandomChase(req, res, next) {
+const getRandomChase = async (req, res, next) => {
try {
const [result] = await Chase.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Chase Gif'))
+ return next(createError(404, 'Could not find any Chase Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { chase: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { chase: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomChase;
diff --git a/src/controllers/gifs/randomCheer.js b/src/controllers/v3/gifs/randomCheer.js
similarity index 59%
rename from src/controllers/gifs/randomCheer.js
rename to src/controllers/v3/gifs/randomCheer.js
index cfc4371..21447b8 100644
--- a/src/controllers/gifs/randomCheer.js
+++ b/src/controllers/v3/gifs/randomCheer.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Cheer = require('../../models/schemas/Cheer')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Cheer from '../../../models/schemas/Cheer.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Cheer
-module.exports = async function getRandomCheer(req, res, next) {
+const getRandomCheer = async (req, res, next) => {
try {
const [result] = await Cheer.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Cheer Gif'))
+ return next(createError(404, 'Could not find any Cheer Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cheer: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cheer: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomCheer;
diff --git a/src/controllers/gifs/randomCringe.js b/src/controllers/v3/gifs/randomCringe.js
similarity index 51%
rename from src/controllers/gifs/randomCringe.js
rename to src/controllers/v3/gifs/randomCringe.js
index d4242c9..3551842 100644
--- a/src/controllers/gifs/randomCringe.js
+++ b/src/controllers/v3/gifs/randomCringe.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Cringe = require('../../models/schemas/Cringe')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Cringe from '../../../models/schemas/Cringe.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Cringe
-module.exports = async function getRandomCringe(req, res, next) {
+const getRandomCringe = async (req, res, next) => {
try {
const [result] = await Cringe.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Cringe Gif'))
+ return next(createError(404, 'Could not find any Cringe Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { cringe: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cringe: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomCringe;
diff --git a/src/controllers/gifs/randomCry.js b/src/controllers/v3/gifs/randomCry.js
similarity index 60%
rename from src/controllers/gifs/randomCry.js
rename to src/controllers/v3/gifs/randomCry.js
index 0dcd213..80d80e5 100644
--- a/src/controllers/gifs/randomCry.js
+++ b/src/controllers/v3/gifs/randomCry.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Cry = require('../../models/schemas/Cry')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Cry from '../../../models/schemas/Cry.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Cry
-module.exports = async function getRandomCry(req, res, next) {
+const getRandomCry = async (req, res, next) => {
try {
const [result] = await Cry.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Cry Gif'))
+ return next(createError(404, 'Could not find any Cry Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cry: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cry: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomCry;
diff --git a/src/controllers/gifs/randomCuddle.js b/src/controllers/v3/gifs/randomCuddle.js
similarity index 51%
rename from src/controllers/gifs/randomCuddle.js
rename to src/controllers/v3/gifs/randomCuddle.js
index 5d567f9..f5f5314 100644
--- a/src/controllers/gifs/randomCuddle.js
+++ b/src/controllers/v3/gifs/randomCuddle.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Cuddle = require('../../models/schemas/Cuddle')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Cuddle from '../../../models/schemas/Cuddle.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Cuddle
-module.exports = async function getRandomCuddle(req, res, next) {
+const getRandomCuddle = async (req, res, next) => {
try {
const [result] = await Cuddle.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Cuddle Gif'))
+ return next(createError(404, 'Could not find any Cuddle Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { cuddle: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cuddle: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomCuddle;
diff --git a/src/controllers/gifs/randomDab.js b/src/controllers/v3/gifs/randomDab.js
similarity index 60%
rename from src/controllers/gifs/randomDab.js
rename to src/controllers/v3/gifs/randomDab.js
index 15d34c8..d95f2df 100644
--- a/src/controllers/gifs/randomDab.js
+++ b/src/controllers/v3/gifs/randomDab.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Dab = require('../../models/schemas/Dab')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Dab from '../../../models/schemas/Dab.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Dab
-module.exports = async function getRandomDab(req, res, next) {
+const getRandomDab = async (req, res, next) => {
try {
const [result] = await Dab.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Dab Gif'))
+ return next(createError(404, 'Could not find any Dab Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { dab: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { dab: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomDab;
diff --git a/src/controllers/gifs/randomDance.js b/src/controllers/v3/gifs/randomDance.js
similarity index 59%
rename from src/controllers/gifs/randomDance.js
rename to src/controllers/v3/gifs/randomDance.js
index cab5b04..922e5e3 100644
--- a/src/controllers/gifs/randomDance.js
+++ b/src/controllers/v3/gifs/randomDance.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Dance = require('../../models/schemas/Dance')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Dance from '../../../models/schemas/Dance.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Dance
-module.exports = async function getRandomDance(req, res, next) {
+const getRandomDance = async (req, res, next) => {
try {
const [result] = await Dance.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Dance Gif'))
+ return next(createError(404, 'Could not find any Dance Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { dance: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { dance: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomDance;
diff --git a/src/controllers/gifs/randomDie.js b/src/controllers/v3/gifs/randomDie.js
similarity index 60%
rename from src/controllers/gifs/randomDie.js
rename to src/controllers/v3/gifs/randomDie.js
index e93091a..da8936c 100644
--- a/src/controllers/gifs/randomDie.js
+++ b/src/controllers/v3/gifs/randomDie.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Die = require('../../models/schemas/Die')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Die from '../../../models/schemas/Die.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Die
-module.exports = async function getRandomDie(req, res, next) {
+const getRandomDie = async (req, res, next) => {
try {
const [result] = await Die.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Die Gif'))
+ return next(createError(404, 'Could not find any Die Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { die: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { die: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomDie;
diff --git a/src/controllers/gifs/randomDisgust.js b/src/controllers/v3/gifs/randomDisgust.js
similarity index 51%
rename from src/controllers/gifs/randomDisgust.js
rename to src/controllers/v3/gifs/randomDisgust.js
index da0d794..f52edbe 100644
--- a/src/controllers/gifs/randomDisgust.js
+++ b/src/controllers/v3/gifs/randomDisgust.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Disgust = require('../../models/schemas/Disgust')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Disgust from '../../../models/schemas/Disgust.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Disgust
-module.exports = async function getRandomDisgust(req, res, next) {
+const getRandomDisgust = async (req, res, next) => {
try {
const [result] = await Disgust.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Disgust Gif'))
+ return next(createError(404, 'Could not find any Disgust Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { disgust: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { disgust: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomDisgust;
diff --git a/src/controllers/gifs/randomFacepalm.js b/src/controllers/v3/gifs/randomFacepalm.js
similarity index 51%
rename from src/controllers/gifs/randomFacepalm.js
rename to src/controllers/v3/gifs/randomFacepalm.js
index 3b975c1..4d1751b 100644
--- a/src/controllers/gifs/randomFacepalm.js
+++ b/src/controllers/v3/gifs/randomFacepalm.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Facepalm = require('../../models/schemas/Facepalm')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Facepalm from '../../../models/schemas/Facepalm.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Facepalm
-module.exports = async function getRandomFacepalm(req, res, next) {
+const getRandomFacepalm = async (req, res, next) => {
try {
const [result] = await Facepalm.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Facepalm Gif'))
+ return next(createError(404, 'Could not find any Facepalm Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { facepalm: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { facepalm: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomFacepalm;
diff --git a/src/controllers/gifs/randomFeed.js b/src/controllers/v3/gifs/randomFeed.js
similarity index 59%
rename from src/controllers/gifs/randomFeed.js
rename to src/controllers/v3/gifs/randomFeed.js
index 2abc733..930e163 100644
--- a/src/controllers/gifs/randomFeed.js
+++ b/src/controllers/v3/gifs/randomFeed.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Feed = require('../../models/schemas/Feed')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Feed from '../../../models/schemas/Feed.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Feed
-module.exports = async function getRandomFeed(req, res, next) {
+const getRandomFeed = async (req, res, next) => {
try {
const [result] = await Feed.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Feed Gif'))
+ return next(createError(404, 'Could not find any Feed Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { feed: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { feed: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomFeed;
diff --git a/src/controllers/gifs/randomGlomp.js b/src/controllers/v3/gifs/randomGlomp.js
similarity index 59%
rename from src/controllers/gifs/randomGlomp.js
rename to src/controllers/v3/gifs/randomGlomp.js
index e9cfc85..2fd4029 100644
--- a/src/controllers/gifs/randomGlomp.js
+++ b/src/controllers/v3/gifs/randomGlomp.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Glomp = require('../../models/schemas/Glomp')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Glomp from '../../../models/schemas/Glomp.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Glomp
-module.exports = async function getRandomGlomp(req, res, next) {
+const getRandomGlomp = async (req, res, next) => {
try {
const [result] = await Glomp.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Glomp Gif'))
+ return next(createError(404, 'Could not find any Glomp Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { glomp: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { glomp: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomGlomp;
diff --git a/src/controllers/gifs/randomHappy.js b/src/controllers/v3/gifs/randomHappy.js
similarity index 59%
rename from src/controllers/gifs/randomHappy.js
rename to src/controllers/v3/gifs/randomHappy.js
index d5e45f9..59de724 100644
--- a/src/controllers/gifs/randomHappy.js
+++ b/src/controllers/v3/gifs/randomHappy.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Happy = require('../../models/schemas/Happy')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Happy from '../../../models/schemas/Happy.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Happy
-module.exports = async function getRandomHappy(req, res, next) {
+const getRandomHappy = async (req, res, next) => {
try {
const [result] = await Happy.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Happy Gif'))
+ return next(createError(404, 'Could not find any Happy Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { happy: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { happy: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomHappy;
diff --git a/src/controllers/gifs/randomHi.js b/src/controllers/v3/gifs/randomHi.js
similarity index 60%
rename from src/controllers/gifs/randomHi.js
rename to src/controllers/v3/gifs/randomHi.js
index 942a0ab..d2614d7 100644
--- a/src/controllers/gifs/randomHi.js
+++ b/src/controllers/v3/gifs/randomHi.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Hi = require('../../models/schemas/Hi')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Hi from '../../../models/schemas/Hi.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Hi
-module.exports = async function getRandomHi(req, res, next) {
+const getRandomHi = async (req, res, next) => {
try {
const [result] = await Hi.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Hi Gif'))
+ return next(createError(404, 'Could not find any Hi Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hi: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hi: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomHi;
diff --git a/src/controllers/gifs/randomHighfive.js b/src/controllers/v3/gifs/randomHighfive.js
similarity index 51%
rename from src/controllers/gifs/randomHighfive.js
rename to src/controllers/v3/gifs/randomHighfive.js
index 44e0ba6..c290116 100644
--- a/src/controllers/gifs/randomHighfive.js
+++ b/src/controllers/v3/gifs/randomHighfive.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Highfive = require('../../models/schemas/Highfive')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Highfive from '../../../models/schemas/Highfive.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Highfive
-module.exports = async function getRandomHighfive(req, res, next) {
+const getRandomHighfive = async (req, res, next) => {
try {
const [result] = await Highfive.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Highfive Gif'))
+ return next(createError(404, 'Could not find any Highfive Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { highfive: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { highfive: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomHighfive;
diff --git a/src/controllers/gifs/randomHold.js b/src/controllers/v3/gifs/randomHold.js
similarity index 59%
rename from src/controllers/gifs/randomHold.js
rename to src/controllers/v3/gifs/randomHold.js
index 7537186..9640b64 100644
--- a/src/controllers/gifs/randomHold.js
+++ b/src/controllers/v3/gifs/randomHold.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Hold = require('../../models/schemas/Hold')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Hold from '../../../models/schemas/Hold.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Hold
-module.exports = async function getRandomHold(req, res, next) {
+const getRandomHold = async (req, res, next) => {
try {
const [result] = await Hold.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Hold Gif'))
+ return next(createError(404, 'Could not find any Hold Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hold: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hold: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomHold;
diff --git a/src/controllers/gifs/randomHug.js b/src/controllers/v3/gifs/randomHug.js
similarity index 60%
rename from src/controllers/gifs/randomHug.js
rename to src/controllers/v3/gifs/randomHug.js
index 02bf136..8d3432f 100644
--- a/src/controllers/gifs/randomHug.js
+++ b/src/controllers/v3/gifs/randomHug.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Hug = require('../../models/schemas/Hug')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Hug from '../../../models/schemas/Hug.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Hug
-module.exports = async function getRandomHug(req, res, next) {
+const getRandomHug = async (req, res, next) => {
try {
const [result] = await Hug.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Hug Gif'))
+ return next(createError(404, 'Could not find any Hug Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hug: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hug: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomHug;
diff --git a/src/controllers/gifs/randomKick.js b/src/controllers/v3/gifs/randomKick.js
similarity index 59%
rename from src/controllers/gifs/randomKick.js
rename to src/controllers/v3/gifs/randomKick.js
index 6300439..b24d888 100644
--- a/src/controllers/gifs/randomKick.js
+++ b/src/controllers/v3/gifs/randomKick.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Kick = require('../../models/schemas/Kick')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Kick from '../../../models/schemas/Kick.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Kick
-module.exports = async function getRandomKick(req, res, next) {
+const getRandomKick = async (req, res, next) => {
try {
const [result] = await Kick.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Kick Gif'))
+ return next(createError(404, 'Could not find any Kick Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kick: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kick: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomKick;
diff --git a/src/controllers/gifs/randomKill.js b/src/controllers/v3/gifs/randomKill.js
similarity index 59%
rename from src/controllers/gifs/randomKill.js
rename to src/controllers/v3/gifs/randomKill.js
index 266ba69..7186102 100644
--- a/src/controllers/gifs/randomKill.js
+++ b/src/controllers/v3/gifs/randomKill.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Kill = require('../../models/schemas/Kill')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Kill from '../../../models/schemas/Kill.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Kill
-module.exports = async function getRandomKill(req, res, next) {
+const getRandomKill = async (req, res, next) => {
try {
const [result] = await Kill.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Kill Gif'))
+ return next(createError(404, 'Could not find any Kill Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kill: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kill: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomKill;
diff --git a/src/controllers/gifs/randomKissu.js b/src/controllers/v3/gifs/randomKissu.js
similarity index 59%
rename from src/controllers/gifs/randomKissu.js
rename to src/controllers/v3/gifs/randomKissu.js
index 7d596da..a13ce66 100644
--- a/src/controllers/gifs/randomKissu.js
+++ b/src/controllers/v3/gifs/randomKissu.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Kissu = require('../../models/schemas/Kissu')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Kissu from '../../../models/schemas/Kissu.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Kissu
-module.exports = async function getRandomKissu(req, res, next) {
+const getRandomKissu = async (req, res, next) => {
try {
const [result] = await Kissu.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Kissu Gif'))
+ return next(createError(404, 'Could not find any Kissu Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kissu: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kissu: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomKissu;
diff --git a/src/controllers/gifs/randomLaugh.js b/src/controllers/v3/gifs/randomLaugh.js
similarity index 59%
rename from src/controllers/gifs/randomLaugh.js
rename to src/controllers/v3/gifs/randomLaugh.js
index 8e95f98..7450f79 100644
--- a/src/controllers/gifs/randomLaugh.js
+++ b/src/controllers/v3/gifs/randomLaugh.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Laugh = require('../../models/schemas/Laugh')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Laugh from '../../../models/schemas/Laugh.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Laugh
-module.exports = async function getRandomLaugh(req, res, next) {
+const getRandomLaugh = async (req, res, next) => {
try {
const [result] = await Laugh.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Laugh Gif'))
+ return next(createError(404, 'Could not find any Laugh Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { laugh: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { laugh: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomLaugh;
diff --git a/src/controllers/gifs/randomLick.js b/src/controllers/v3/gifs/randomLick.js
similarity index 59%
rename from src/controllers/gifs/randomLick.js
rename to src/controllers/v3/gifs/randomLick.js
index c62ee7e..df87eb8 100644
--- a/src/controllers/gifs/randomLick.js
+++ b/src/controllers/v3/gifs/randomLick.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Lick = require('../../models/schemas/Lick')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Lick from '../../../models/schemas/Lick.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Lick
-module.exports = async function getRandomLick(req, res, next) {
+const getRandomLick = async (req, res, next) => {
try {
const [result] = await Lick.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Lick Gif'))
+ return next(createError(404, 'Could not find any Lick Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { lick: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { lick: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomLick;
diff --git a/src/controllers/gifs/randomLove.js b/src/controllers/v3/gifs/randomLove.js
similarity index 59%
rename from src/controllers/gifs/randomLove.js
rename to src/controllers/v3/gifs/randomLove.js
index e9f0e74..a0699e5 100644
--- a/src/controllers/gifs/randomLove.js
+++ b/src/controllers/v3/gifs/randomLove.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Love = require('../../models/schemas/Love')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Love from '../../../models/schemas/Love.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Love
-module.exports = async function getRandomLove(req, res, next) {
+const getRandomLove = async (req, res, next) => {
try {
const [result] = await Love.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Love Gif'))
+ return next(createError(404, 'Could not find any Love Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { love: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { love: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomLove;
diff --git a/src/controllers/gifs/randomLurk.js b/src/controllers/v3/gifs/randomLurk.js
similarity index 59%
rename from src/controllers/gifs/randomLurk.js
rename to src/controllers/v3/gifs/randomLurk.js
index 48a5a00..74e36f7 100644
--- a/src/controllers/gifs/randomLurk.js
+++ b/src/controllers/v3/gifs/randomLurk.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Lurk = require('../../models/schemas/Lurk')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Lurk from '../../../models/schemas/Lurk.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Lurk
-module.exports = async function getRandomLurk(req, res, next) {
+const getRandomLurk = async (req, res, next) => {
try {
const [result] = await Lurk.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Lurk Gif'))
+ return next(createError(404, 'Could not find any Lurk Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { lurk: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { lurk: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomLurk;
diff --git a/src/controllers/v3/gifs/randomMidfing.js b/src/controllers/v3/gifs/randomMidfing.js
new file mode 100644
index 0000000..6290752
--- /dev/null
+++ b/src/controllers/v3/gifs/randomMidfing.js
@@ -0,0 +1,31 @@
+
+import createError from 'http-errors';
+import Midfing from '../../../models/schemas/Midfing.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Midfing
+const getRandomMidfing = async (req, res, next) => {
+ try {
+ const [result] = await Midfing.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Midfing Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { midfing: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomMidfing;
diff --git a/src/controllers/v3/gifs/randomNervous.js b/src/controllers/v3/gifs/randomNervous.js
new file mode 100644
index 0000000..5a2616b
--- /dev/null
+++ b/src/controllers/v3/gifs/randomNervous.js
@@ -0,0 +1,31 @@
+
+import createError from 'http-errors';
+import Nervous from '../../../models/schemas/Nervous.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Nervous
+const getRandomNervous = async (req, res, next) => {
+ try {
+ const [result] = await Nervous.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Nervous Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nervous: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomNervous;
diff --git a/src/controllers/gifs/randomNom.js b/src/controllers/v3/gifs/randomNom.js
similarity index 60%
rename from src/controllers/gifs/randomNom.js
rename to src/controllers/v3/gifs/randomNom.js
index f75e8f6..00f9b20 100644
--- a/src/controllers/gifs/randomNom.js
+++ b/src/controllers/v3/gifs/randomNom.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Nom = require('../../models/schemas/Nom')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Nom from '../../../models/schemas/Nom.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Nom
-module.exports = async function getRandomNom(req, res, next) {
+const getRandomNom = async (req, res, next) => {
try {
const [result] = await Nom.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Nom Gif'))
+ return next(createError(404, 'Could not find any Nom Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nom: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nom: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomNom;
diff --git a/src/controllers/gifs/randomNope.js b/src/controllers/v3/gifs/randomNope.js
similarity index 59%
rename from src/controllers/gifs/randomNope.js
rename to src/controllers/v3/gifs/randomNope.js
index d4f640b..348aa18 100644
--- a/src/controllers/gifs/randomNope.js
+++ b/src/controllers/v3/gifs/randomNope.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Nope = require('../../models/schemas/Nope')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Nope from '../../../models/schemas/Nope.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Nope
-module.exports = async function getRandomNope(req, res, next) {
+const getRandomNope = async (req, res, next) => {
try {
const [result] = await Nope.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Nope Gif'))
+ return next(createError(404, 'Could not find any Nope Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nope: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nope: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomNope;
diff --git a/src/controllers/gifs/randomNuzzle.js b/src/controllers/v3/gifs/randomNuzzle.js
similarity index 51%
rename from src/controllers/gifs/randomNuzzle.js
rename to src/controllers/v3/gifs/randomNuzzle.js
index ad2e471..38e1f7b 100644
--- a/src/controllers/gifs/randomNuzzle.js
+++ b/src/controllers/v3/gifs/randomNuzzle.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Nuzzle = require('../../models/schemas/Nuzzle')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Nuzzle from '../../../models/schemas/Nuzzle.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Nuzzle
-module.exports = async function getRandomNuzzle(req, res, next) {
+const getRandomNuzzle = async (req, res, next) => {
try {
const [result] = await Nuzzle.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Nuzzle Gif'))
+ return next(createError(404, 'Could not find any Nuzzle Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { nuzzle: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nuzzle: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomNuzzle;
diff --git a/src/controllers/gifs/randomPanic.js b/src/controllers/v3/gifs/randomPanic.js
similarity index 59%
rename from src/controllers/gifs/randomPanic.js
rename to src/controllers/v3/gifs/randomPanic.js
index 167cd10..abf97e0 100644
--- a/src/controllers/gifs/randomPanic.js
+++ b/src/controllers/v3/gifs/randomPanic.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Panic = require('../../models/schemas/Panic')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Panic from '../../../models/schemas/Panic.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Panic
-module.exports = async function getRandomPanic(req, res, next) {
+const getRandomPanic = async (req, res, next) => {
try {
const [result] = await Panic.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Panic Gif'))
+ return next(createError(404, 'Could not find any Panic Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { panic: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { panic: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomPanic;
diff --git a/src/controllers/gifs/randomPat.js b/src/controllers/v3/gifs/randomPat.js
similarity index 60%
rename from src/controllers/gifs/randomPat.js
rename to src/controllers/v3/gifs/randomPat.js
index 4749a17..bd683d9 100644
--- a/src/controllers/gifs/randomPat.js
+++ b/src/controllers/v3/gifs/randomPat.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Pat = require('../../models/schemas/Pat')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Pat from '../../../models/schemas/Pat.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Pat
-module.exports = async function getRandomPat(req, res, next) {
+const getRandomPat = async (req, res, next) => {
try {
const [result] = await Pat.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Pat Gif'))
+ return next(createError(404, 'Could not find any Pat Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { pat: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { pat: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomPat;
diff --git a/src/controllers/gifs/randomPeck.js b/src/controllers/v3/gifs/randomPeck.js
similarity index 59%
rename from src/controllers/gifs/randomPeck.js
rename to src/controllers/v3/gifs/randomPeck.js
index 408e512..fb96e43 100644
--- a/src/controllers/gifs/randomPeck.js
+++ b/src/controllers/v3/gifs/randomPeck.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Peck = require('../../models/schemas/Peck')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Peck from '../../../models/schemas/Peck.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Peck
-module.exports = async function getRandomPeck(req, res, next) {
+const getRandomPeck = async (req, res, next) => {
try {
const [result] = await Peck.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Peck Gif'))
+ return next(createError(404, 'Could not find any Peck Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { peck: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { peck: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomPeck;
diff --git a/src/controllers/gifs/randomPoke.js b/src/controllers/v3/gifs/randomPoke.js
similarity index 59%
rename from src/controllers/gifs/randomPoke.js
rename to src/controllers/v3/gifs/randomPoke.js
index c817b6c..4b2c428 100644
--- a/src/controllers/gifs/randomPoke.js
+++ b/src/controllers/v3/gifs/randomPoke.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Poke = require('../../models/schemas/Poke')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Poke from '../../../models/schemas/Poke.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Poke
-module.exports = async function getRandomPoke(req, res, next) {
+const getRandomPoke = async (req, res, next) => {
try {
const [result] = await Poke.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Poke Gif'))
+ return next(createError(404, 'Could not find any Poke Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { poke: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { poke: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomPoke;
diff --git a/src/controllers/gifs/randomPout.js b/src/controllers/v3/gifs/randomPout.js
similarity index 59%
rename from src/controllers/gifs/randomPout.js
rename to src/controllers/v3/gifs/randomPout.js
index 6babcb2..dc45330 100644
--- a/src/controllers/gifs/randomPout.js
+++ b/src/controllers/v3/gifs/randomPout.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Pout = require('../../models/schemas/Pout')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Pout from '../../../models/schemas/Pout.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Pout
-module.exports = async function getRandomPout(req, res, next) {
+const getRandomPout = async (req, res, next) => {
try {
const [result] = await Pout.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Pout Gif'))
+ return next(createError(404, 'Could not find any Pout Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { pout: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { pout: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomPout;
diff --git a/src/controllers/gifs/randomPunch.js b/src/controllers/v3/gifs/randomPunch.js
similarity index 59%
rename from src/controllers/gifs/randomPunch.js
rename to src/controllers/v3/gifs/randomPunch.js
index fc7a704..dd35b84 100644
--- a/src/controllers/gifs/randomPunch.js
+++ b/src/controllers/v3/gifs/randomPunch.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Punch = require('../../models/schemas/Punch')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Punch from '../../../models/schemas/Punch.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Punch
-module.exports = async function getRandomPunch(req, res, next) {
+const getRandomPunch = async (req, res, next) => {
try {
const [result] = await Punch.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Punch Gif'))
+ return next(createError(404, 'Could not find any Punch Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { punch: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { punch: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomPunch;
diff --git a/src/controllers/gifs/randomRun.js b/src/controllers/v3/gifs/randomRun.js
similarity index 60%
rename from src/controllers/gifs/randomRun.js
rename to src/controllers/v3/gifs/randomRun.js
index 735f7a2..061d36f 100644
--- a/src/controllers/gifs/randomRun.js
+++ b/src/controllers/v3/gifs/randomRun.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Run = require('../../models/schemas/Run')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Run from '../../../models/schemas/Run.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Run
-module.exports = async function getRandomRun(req, res, next) {
+const getRandomRun = async (req, res, next) => {
try {
const [result] = await Run.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Run Gif'))
+ return next(createError(404, 'Could not find any Run Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { run: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { run: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomRun;
diff --git a/src/controllers/gifs/randomSad.js b/src/controllers/v3/gifs/randomSad.js
similarity index 60%
rename from src/controllers/gifs/randomSad.js
rename to src/controllers/v3/gifs/randomSad.js
index 769866c..0af254d 100644
--- a/src/controllers/gifs/randomSad.js
+++ b/src/controllers/v3/gifs/randomSad.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Sad = require('../../models/schemas/Sad')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Sad from '../../../models/schemas/Sad.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Sad
-module.exports = async function getRandomSad(req, res, next) {
+const getRandomSad = async (req, res, next) => {
try {
const [result] = await Sad.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Sad Gif'))
+ return next(createError(404, 'Could not find any Sad Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sad: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sad: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSad;
diff --git a/src/controllers/gifs/randomShoot.js b/src/controllers/v3/gifs/randomShoot.js
similarity index 59%
rename from src/controllers/gifs/randomShoot.js
rename to src/controllers/v3/gifs/randomShoot.js
index 0df7c36..cdc8a1b 100644
--- a/src/controllers/gifs/randomShoot.js
+++ b/src/controllers/v3/gifs/randomShoot.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Shoot = require('../../models/schemas/Shoot')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Shoot from '../../../models/schemas/Shoot.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Shoot
-module.exports = async function getRandomShoot(req, res, next) {
+const getRandomShoot = async (req, res, next) => {
try {
const [result] = await Shoot.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Shoot Gif'))
+ return next(createError(404, 'Could not find any Shoot Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { shoot: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { shoot: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomShoot;
diff --git a/src/controllers/gifs/randomShrug.js b/src/controllers/v3/gifs/randomShrug.js
similarity index 59%
rename from src/controllers/gifs/randomShrug.js
rename to src/controllers/v3/gifs/randomShrug.js
index 51fbb42..9755221 100644
--- a/src/controllers/gifs/randomShrug.js
+++ b/src/controllers/v3/gifs/randomShrug.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Shrug = require('../../models/schemas/Shrug')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Shrug from '../../../models/schemas/Shrug.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Shrug
-module.exports = async function getRandomShrug(req, res, next) {
+const getRandomShrug = async (req, res, next) => {
try {
const [result] = await Shrug.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Shrug Gif'))
+ return next(createError(404, 'Could not find any Shrug Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { shrug: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { shrug: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomShrug;
diff --git a/src/controllers/gifs/randomSip.js b/src/controllers/v3/gifs/randomSip.js
similarity index 60%
rename from src/controllers/gifs/randomSip.js
rename to src/controllers/v3/gifs/randomSip.js
index f2c240f..37fcea4 100644
--- a/src/controllers/gifs/randomSip.js
+++ b/src/controllers/v3/gifs/randomSip.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Sip = require('../../models/schemas/Sip')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Sip from '../../../models/schemas/Sip.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Sip
-module.exports = async function getRandomSip(req, res, next) {
+const getRandomSip = async (req, res, next) => {
try {
const [result] = await Sip.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Sip Gif'))
+ return next(createError(404, 'Could not find any Sip Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sip: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sip: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSip;
diff --git a/src/controllers/gifs/randomSlap.js b/src/controllers/v3/gifs/randomSlap.js
similarity index 59%
rename from src/controllers/gifs/randomSlap.js
rename to src/controllers/v3/gifs/randomSlap.js
index db83bbc..89fb3e5 100644
--- a/src/controllers/gifs/randomSlap.js
+++ b/src/controllers/v3/gifs/randomSlap.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Slap = require('../../models/schemas/Slap')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Slap from '../../../models/schemas/Slap.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Slap
-module.exports = async function getRandomSlap(req, res, next) {
+const getRandomSlap = async (req, res, next) => {
try {
const [result] = await Slap.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Slap Gif'))
+ return next(createError(404, 'Could not find any Slap Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { slap: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { slap: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSlap;
diff --git a/src/controllers/gifs/randomSleepy.js b/src/controllers/v3/gifs/randomSleepy.js
similarity index 51%
rename from src/controllers/gifs/randomSleepy.js
rename to src/controllers/v3/gifs/randomSleepy.js
index a8d97b0..a408099 100644
--- a/src/controllers/gifs/randomSleepy.js
+++ b/src/controllers/v3/gifs/randomSleepy.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Sleepy = require('../../models/schemas/Sleepy')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Sleepy from '../../../models/schemas/Sleepy.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Sleepy
-module.exports = async function getRandomSleepy(req, res, next) {
+const getRandomSleepy = async (req, res, next) => {
try {
const [result] = await Sleepy.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Sleepy Gif'))
+ return next(createError(404, 'Could not find any Sleepy Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { sleepy: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sleepy: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSleepy;
diff --git a/src/controllers/gifs/randomSmile.js b/src/controllers/v3/gifs/randomSmile.js
similarity index 59%
rename from src/controllers/gifs/randomSmile.js
rename to src/controllers/v3/gifs/randomSmile.js
index 1131008..54983e2 100644
--- a/src/controllers/gifs/randomSmile.js
+++ b/src/controllers/v3/gifs/randomSmile.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Smile = require('../../models/schemas/Smile')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Smile from '../../../models/schemas/Smile.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Smile
-module.exports = async function getRandomSmile(req, res, next) {
+const getRandomSmile = async (req, res, next) => {
try {
const [result] = await Smile.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Smile Gif'))
+ return next(createError(404, 'Could not find any Smile Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { smile: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { smile: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSmile;
diff --git a/src/controllers/gifs/randomSmug.js b/src/controllers/v3/gifs/randomSmug.js
similarity index 59%
rename from src/controllers/gifs/randomSmug.js
rename to src/controllers/v3/gifs/randomSmug.js
index 55adb87..8861730 100644
--- a/src/controllers/gifs/randomSmug.js
+++ b/src/controllers/v3/gifs/randomSmug.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Smug = require('../../models/schemas/Smug')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Smug from '../../../models/schemas/Smug.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Smug
-module.exports = async function getRandomSmug(req, res, next) {
+const getRandomSmug = async (req, res, next) => {
try {
const [result] = await Smug.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Smug Gif'))
+ return next(createError(404, 'Could not find any Smug Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { smug: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { smug: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSmug;
diff --git a/src/controllers/gifs/randomStab.js b/src/controllers/v3/gifs/randomStab.js
similarity index 59%
rename from src/controllers/gifs/randomStab.js
rename to src/controllers/v3/gifs/randomStab.js
index 93390e5..3b0ce94 100644
--- a/src/controllers/gifs/randomStab.js
+++ b/src/controllers/v3/gifs/randomStab.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Stab = require('../../models/schemas/Stab')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Stab from '../../../models/schemas/Stab.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Stab
-module.exports = async function getRandomStab(req, res, next) {
+const getRandomStab = async (req, res, next) => {
try {
const [result] = await Stab.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Stab Gif'))
+ return next(createError(404, 'Could not find any Stab Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { stab: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { stab: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomStab;
diff --git a/src/controllers/gifs/randomStare.js b/src/controllers/v3/gifs/randomStare.js
similarity index 59%
rename from src/controllers/gifs/randomStare.js
rename to src/controllers/v3/gifs/randomStare.js
index 221f32d..b1c2979 100644
--- a/src/controllers/gifs/randomStare.js
+++ b/src/controllers/v3/gifs/randomStare.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Stare = require('../../models/schemas/Stare')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Stare from '../../../models/schemas/Stare.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Stare
-module.exports = async function getRandomStare(req, res, next) {
+const getRandomStare = async (req, res, next) => {
try {
const [result] = await Stare.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Stare Gif'))
+ return next(createError(404, 'Could not find any Stare Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { stare: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { stare: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomStare;
diff --git a/src/controllers/gifs/randomSuicide.js b/src/controllers/v3/gifs/randomSuicide.js
similarity index 51%
rename from src/controllers/gifs/randomSuicide.js
rename to src/controllers/v3/gifs/randomSuicide.js
index 4247bd8..f3d355c 100644
--- a/src/controllers/gifs/randomSuicide.js
+++ b/src/controllers/v3/gifs/randomSuicide.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Suicide = require('../../models/schemas/Suicide')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Suicide from '../../../models/schemas/Suicide.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Suicide
-module.exports = async function getRandomSuicide(req, res, next) {
+const getRandomSuicide = async (req, res, next) => {
try {
const [result] = await Suicide.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Suicide Gif'))
+ return next(createError(404, 'Could not find any Suicide Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { suicide: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { suicide: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomSuicide;
diff --git a/src/controllers/gifs/randomTease.js b/src/controllers/v3/gifs/randomTease.js
similarity index 59%
rename from src/controllers/gifs/randomTease.js
rename to src/controllers/v3/gifs/randomTease.js
index d698d21..5698856 100644
--- a/src/controllers/gifs/randomTease.js
+++ b/src/controllers/v3/gifs/randomTease.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Tease = require('../../models/schemas/Tease')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Tease from '../../../models/schemas/Tease.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Tease
-module.exports = async function getRandomTease(req, res, next) {
+const getRandomTease = async (req, res, next) => {
try {
const [result] = await Tease.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Tease Gif'))
+ return next(createError(404, 'Could not find any Tease Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { tease: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { tease: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomTease;
diff --git a/src/controllers/gifs/randomThink.js b/src/controllers/v3/gifs/randomThink.js
similarity index 59%
rename from src/controllers/gifs/randomThink.js
rename to src/controllers/v3/gifs/randomThink.js
index d7c73b9..0afad57 100644
--- a/src/controllers/gifs/randomThink.js
+++ b/src/controllers/v3/gifs/randomThink.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Think = require('../../models/schemas/Think')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Think from '../../../models/schemas/Think.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Think
-module.exports = async function getRandomThink(req, res, next) {
+const getRandomThink = async (req, res, next) => {
try {
const [result] = await Think.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Think Gif'))
+ return next(createError(404, 'Could not find any Think Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { think: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { think: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomThink;
diff --git a/src/controllers/gifs/randomThumbsup.js b/src/controllers/v3/gifs/randomThumbsup.js
similarity index 51%
rename from src/controllers/gifs/randomThumbsup.js
rename to src/controllers/v3/gifs/randomThumbsup.js
index 05dc315..6a2d1bd 100644
--- a/src/controllers/gifs/randomThumbsup.js
+++ b/src/controllers/v3/gifs/randomThumbsup.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Thumbsup = require('../../models/schemas/Thumbsup')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Thumbsup from '../../../models/schemas/Thumbsup.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Thumbsup
-module.exports = async function getRandomThumbsup(req, res, next) {
+const getRandomThumbsup = async (req, res, next) => {
try {
const [result] = await Thumbsup.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Thumbsup Gif'))
+ return next(createError(404, 'Could not find any Thumbsup Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { thumbsup: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { thumbsup: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomThumbsup;
diff --git a/src/controllers/gifs/randomTickle.js b/src/controllers/v3/gifs/randomTickle.js
similarity index 51%
rename from src/controllers/gifs/randomTickle.js
rename to src/controllers/v3/gifs/randomTickle.js
index b9da123..06e4bd2 100644
--- a/src/controllers/gifs/randomTickle.js
+++ b/src/controllers/v3/gifs/randomTickle.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Tickle = require('../../models/schemas/Tickle')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Tickle from '../../../models/schemas/Tickle.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Tickle
-module.exports = async function getRandomTickle(req, res, next) {
+const getRandomTickle = async (req, res, next) => {
try {
const [result] = await Tickle.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Tickle Gif'))
+ return next(createError(404, 'Could not find any Tickle Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { tickle: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { tickle: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomTickle;
diff --git a/src/controllers/gifs/randomTriggered.js b/src/controllers/v3/gifs/randomTriggered.js
similarity index 50%
rename from src/controllers/gifs/randomTriggered.js
rename to src/controllers/v3/gifs/randomTriggered.js
index 8e6cdc4..bfbc35e 100644
--- a/src/controllers/gifs/randomTriggered.js
+++ b/src/controllers/v3/gifs/randomTriggered.js
@@ -1,31 +1,31 @@
-const createError = require('http-errors')
-const Triggered = require('../../models/schemas/Triggered')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Triggered from '../../../models/schemas/Triggered.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Triggered
-module.exports = async function getRandomTriggered(req, res, next) {
+const getRandomTriggered = async (req, res, next) => {
try {
const [result] = await Triggered.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Triggered Gif'))
+ return next(createError(404, 'Could not find any Triggered Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate(
- { _id: 'systemstats' },
- { $inc: { triggered: 1 } }
- )
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { triggered: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomTriggered;
diff --git a/src/controllers/gifs/randomWag.js b/src/controllers/v3/gifs/randomWag.js
similarity index 60%
rename from src/controllers/gifs/randomWag.js
rename to src/controllers/v3/gifs/randomWag.js
index 964d847..88ad360 100644
--- a/src/controllers/gifs/randomWag.js
+++ b/src/controllers/v3/gifs/randomWag.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Wag = require('../../models/schemas/Wag')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Wag from '../../../models/schemas/Wag.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Wag
-module.exports = async function getRandomWag(req, res, next) {
+const getRandomWag = async (req, res, next) => {
try {
const [result] = await Wag.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Wag Gif'))
+ return next(createError(404, 'Could not find any Wag Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wag: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wag: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomWag;
diff --git a/src/controllers/gifs/randomWave.js b/src/controllers/v3/gifs/randomWave.js
similarity index 59%
rename from src/controllers/gifs/randomWave.js
rename to src/controllers/v3/gifs/randomWave.js
index 688491f..195dfb1 100644
--- a/src/controllers/gifs/randomWave.js
+++ b/src/controllers/v3/gifs/randomWave.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Wave = require('../../models/schemas/Wave')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Wave from '../../../models/schemas/Wave.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Wave
-module.exports = async function getRandomWave(req, res, next) {
+const getRandomWave = async (req, res, next) => {
try {
const [result] = await Wave.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Wave Gif'))
+ return next(createError(404, 'Could not find any Wave Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wave: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wave: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomWave;
diff --git a/src/controllers/gifs/randomWink.js b/src/controllers/v3/gifs/randomWink.js
similarity index 59%
rename from src/controllers/gifs/randomWink.js
rename to src/controllers/v3/gifs/randomWink.js
index d6b0c17..fb03a57 100644
--- a/src/controllers/gifs/randomWink.js
+++ b/src/controllers/v3/gifs/randomWink.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Wink = require('../../models/schemas/Wink')
-const Stats = require('../../models/schemas/Stat')
+
+import createError from 'http-errors';
+import Wink from '../../../models/schemas/Wink.js';
+import Stats from '../../../models/schemas/Stat.js';
// Get random Anime Wink
-module.exports = async function getRandomWink(req, res, next) {
+const getRandomWink = async (req, res, next) => {
try {
const [result] = await Wink.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Wink Gif'))
+ return next(createError(404, 'Could not find any Wink Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wink: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wink: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomWink;
diff --git a/src/controllers/gifs/randomYes.js b/src/controllers/v3/gifs/randomYes.js
similarity index 57%
rename from src/controllers/gifs/randomYes.js
rename to src/controllers/v3/gifs/randomYes.js
index 31bdbe8..1408489 100644
--- a/src/controllers/gifs/randomYes.js
+++ b/src/controllers/v3/gifs/randomYes.js
@@ -1,28 +1,31 @@
-const createError = require('http-errors')
-const Yesh = require('../../models/schemas/Yesh')
-const Stats = require('../../models/schemas/Stat')
-// Get random Anime Yesh
-module.exports = async function getRandomYes(req, res, next) {
+import createError from 'http-errors';
+import Yesh from '../../../models/schemas/Yesh.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Yes
+const getRandomYes = async (req, res, next) => {
try {
const [result] = await Yesh.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
- ])
+ ]);
if (!result) {
- return next(createError(404, 'Could not find any Yes Gif'))
+ return next(createError(404, 'Could not find any Yes Gif'));
}
- res.status(200).json(result)
+ res.status(200).json(result);
- await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { yes: 1 } })
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { yes: 1 } });
} catch (error) {
await Stats.findOneAndUpdate(
{ _id: 'systemstats' },
{ $inc: { failed_requests: 1 } }
- )
- return next(error)
+ );
+ return next(error);
}
-}
+};
+
+export default getRandomYes;
diff --git a/src/controllers/v3/quotes/randomQuotes.js b/src/controllers/v3/quotes/randomQuotes.js
new file mode 100644
index 0000000..9ae2cce
--- /dev/null
+++ b/src/controllers/v3/quotes/randomQuotes.js
@@ -0,0 +1,43 @@
+import createError from 'http-errors';
+import Quotes from '../../../models/schemas/Quote.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Gets a random anime quote with optional character filter and updates system statistics.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const getRandomQuote = async (req, res, next) => {
+ try {
+ const { character } = req.query;
+
+ // Create a filter object based on the optional character parameter
+ const filter = character ? { author: character } : {};
+
+ // Aggregate to match the filter, select a random quote, and project excluding version field
+ const [result] = await Quotes.aggregate([
+ { $match: filter }, // Apply filters (if any)
+ { $sample: { size: 1 } }, // Select a random document from the results
+ { $project: { __v: 0 } },
+ ]);
+
+ // If no quote is found, return a 404 error
+ if (!result) {
+ return next(createError(404, 'Could not find any matching Quote'));
+ }
+
+ // Respond with the random quote
+ res.status(200).json(result);
+
+ // Update system statistics for quotes
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { quotes: 1 } });
+ } catch (error) {
+ // Update system statistics for failed requests
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomQuote;
diff --git a/src/controllers/v3/utils/listTags.js b/src/controllers/v3/utils/listTags.js
new file mode 100644
index 0000000..f7b15c1
--- /dev/null
+++ b/src/controllers/v3/utils/listTags.js
@@ -0,0 +1,58 @@
+import Tags from '../../../models/schemas/Tags.js';
+import parseOrder from '../../../modules/parseOrder.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Lists tags with optional sorting and updates system statistics.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const listTags = async (req, res, next) => {
+ try {
+ let { sortBy, sortOrder } = req.query;
+
+ // Supported parameter values
+ const Values = { sortBy: ['name', 'usedCount'] };
+ // The default sort order depends on the `sortBy` field
+ const defaultSortOrder = { name: 1, usedCount: -1 };
+
+ // Validate and set sortBy and sortOrder
+ sortBy = Values.sortBy.includes(sortBy) ? sortBy : 'name';
+ sortOrder = parseOrder(sortOrder) || defaultSortOrder[sortBy] || 1;
+
+ // Aggregate tags, including the count of associated facts, and sort the results
+ const results = await Tags.aggregate([
+ {
+ $lookup: {
+ from: 'facts',
+ localField: 'name',
+ foreignField: 'tags',
+ as: 'usedCount',
+ },
+ },
+ { $addFields: { usedCount: { $size: '$usedCount' } } },
+ { $sort: { [sortBy]: sortOrder } },
+ { $project: { __v: 0 } },
+ ]);
+
+ // Respond with the sorted tags
+ res.json(results);
+
+ // Update system statistics for tags
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { tags: 1 } }
+ );
+ } catch (error) {
+ // Update system statistics for failed requests
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default listTags;
diff --git a/src/controllers/v3/utils/owoify.js b/src/controllers/v3/utils/owoify.js
new file mode 100644
index 0000000..beb1fa0
--- /dev/null
+++ b/src/controllers/v3/utils/owoify.js
@@ -0,0 +1,41 @@
+import createError from 'http-errors';
+import owoify from 'owoify-js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Gets the Owofied version of the provided text and updates system statistics.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const getOwofiyText = async (req, res, next) => {
+ try {
+ const { text } = req.query;
+
+ // Check for valid text input
+ if (!text) {
+ return next(createError(404, 'Invalid text input.'));
+ }
+
+ // Owofy the text and send the response
+ res.status(200).json({
+ text: owoify(text),
+ });
+
+ // Update system statistics for Owofied texts
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { owoify: 1 } }
+ );
+ } catch (error) {
+ // Update system statistics for failed requests
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getOwofiyText;
diff --git a/src/controllers/v3/utils/randomPassword.js b/src/controllers/v3/utils/randomPassword.js
new file mode 100644
index 0000000..fe65922
--- /dev/null
+++ b/src/controllers/v3/utils/randomPassword.js
@@ -0,0 +1,44 @@
+import pass from 'generate-password';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Generates a random password with specified characteristics.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const getRandomPassword = async (req, res, next) => {
+ try {
+ const { charLength } = req.query;
+
+ // Generate a random password with specified characteristics
+ const password = pass.generate({
+ length: charLength || 50,
+ uppercase: true,
+ numbers: true,
+ symbols: true,
+ lowercase: true,
+ strict: true,
+ });
+
+ res.status(200).json({
+ pass: password,
+ });
+
+ // Update system statistics for generated passwords
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { password: 1 } }
+ );
+ } catch (error) {
+ // Update system statistics for failed requests
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomPassword;
diff --git a/src/controllers/v3/utils/user.js b/src/controllers/v3/utils/user.js
new file mode 100644
index 0000000..c255b2b
--- /dev/null
+++ b/src/controllers/v3/utils/user.js
@@ -0,0 +1,96 @@
+import crypto from 'crypto';
+import Users from '../../../models/schemas/User.js';
+import generateToken from '../../../modules/generateToken.js';
+
+/**
+ * Handles user-related operations based on the HTTP method.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const userEndpoint = async (req, res, next) => {
+ try {
+ const { body, headers, method } = req;
+ const { key } = headers;
+
+ // Check for valid access key in headers
+ if (!key || key !== process.env.ACCESS_KEY) {
+ return res.status(401).json({
+ message: 'Unauthorized',
+ });
+ }
+
+ if (method === 'POST') {
+ const { token, id } = body;
+
+ // Check for required fields in the request body
+ if (!token || !id) {
+ return res.status(400).json({
+ message: 'Token and User ID are required in the request body',
+ });
+ }
+
+ // Check if the user with the given _id exists
+ const userExists = await Users.exists({ _id: id });
+
+ if (!userExists) {
+ return res.status(404).json({
+ message: 'User not found',
+ });
+ }
+
+ // Update user's token in the database
+ await Users.updateOne({ _id: { $eq: id } }, { $set: { token: token } });
+
+ return res.status(200).json({
+ message: 'Token updated successfully',
+ });
+ } else if (method === 'GET') {
+ const { id, email, access_token } = headers;
+
+ // Check for required User ID in the headers
+ if (!id) {
+ return res.status(400).json({
+ message: 'User ID missing in the request body',
+ });
+ }
+
+ // Fetch user details based on the provided user ID
+ const user = await Users.findOne({ _id: { $eq: id } });
+
+ if (!user) {
+ // If user not found, create a new user with the provided ID and token
+ const newUser = {
+ _id: id,
+ email: email,
+ password: crypto.randomBytes(22).toString('base64'),
+ token: generateToken(id, process.env.HMAC_KEY),
+ access_token: access_token,
+ // Add other fields in the "newUser" object based on your schema
+ };
+
+ await Users.create(newUser);
+
+ return res.status(201).json(newUser.token);
+ }
+
+ // Update user's token in the database
+ await Users.updateOne(
+ { _id: { $eq: id } },
+ { $set: { access_token: access_token } },
+ { upsert: true }, // Create the document if it doesn't exist
+ );
+
+ return res.status(200).json(user.token);
+ } else {
+ return res.status(405).json({
+ message: 'Method Not Allowed',
+ });
+ }
+ } catch (error) {
+ return next(error);
+ }
+};
+
+export default userEndpoint;
diff --git a/src/controllers/v3/utils/uvuify.js b/src/controllers/v3/utils/uvuify.js
new file mode 100644
index 0000000..e22dee0
--- /dev/null
+++ b/src/controllers/v3/utils/uvuify.js
@@ -0,0 +1,30 @@
+import createError from 'http-errors';
+import uwuify from 'owoify-js';
+import Stats from '../../../models/schemas/Stat.js';
+
+const getOwofiyText = async (req, res, next) => {
+ try {
+ const { text } = req.query;
+
+ if (!text) {
+ return next(createError(404, 'Invalid text input.'));
+ }
+
+ res.status(200).json({
+ text: uwuify(text),
+ });
+
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { uwuify: 1 } }
+ );
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getOwofiyText;
diff --git a/src/controllers/v3/utils/uwuify.js b/src/controllers/v3/utils/uwuify.js
new file mode 100644
index 0000000..02b2f2e
--- /dev/null
+++ b/src/controllers/v3/utils/uwuify.js
@@ -0,0 +1,30 @@
+import createError from 'http-errors';
+import uvuify from 'owoify-js';
+import Stats from '../../../models/schemas/Stat.js';
+
+const getOwofiyText = async (req, res, next) => {
+ try {
+ const { text } = req.query;
+
+ if (!text) {
+ throw createError(404, 'Invalid text input.');
+ }
+
+ res.status(200).json({
+ text: uvuify(text),
+ });
+
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { uvuify: 1 } }
+ );
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ next(error);
+ }
+};
+
+export default getOwofiyText;
diff --git a/src/controllers/v3/waifus/randomWaifus.js b/src/controllers/v3/waifus/randomWaifus.js
new file mode 100644
index 0000000..c6d3554
--- /dev/null
+++ b/src/controllers/v3/waifus/randomWaifus.js
@@ -0,0 +1,22 @@
+import Waifus from '../../../models/schemas/Waifu.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get a random waifu
+const getRandomWaifu = async (req, res, next) => {
+ try {
+ const [result] = await Waifus.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0 } },
+ ]);
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { waifus: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ next(error);
+ }
+};
+
+export default getRandomWaifu;
diff --git a/src/controllers/v4/images/waifu.js b/src/controllers/v4/images/waifu.js
new file mode 100644
index 0000000..fdb4af2
--- /dev/null
+++ b/src/controllers/v4/images/waifu.js
@@ -0,0 +1,97 @@
+import _ from 'lodash';
+import createError from 'http-errors';
+import Waifus from '../../../models/schemas/Waifu.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Gets a random waifu and updates system statistics.
+ *
+ * @function
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ *
+ * @throws {Error} If there is an error during waifu retrieval or database update.
+ *
+ * @returns {Object} JSON object containing the random waifu.
+ * @example
+ * // Example usage in Express route handler
+ * getWaifu(req, res, next);
+ */
+const getWaifu = async (req, res, next) => {
+ try {
+ /**
+ * Extracts character name and anime parameters from the request query.
+ * @type {Object}
+ */
+ const { name, anime } = req.query;
+
+ /**
+ * Holds the filter object based on the optional character name and anime name parameters.
+ * @type {Object}
+ */
+ const filter = {};
+
+ /**
+ * Add conditions to filter object based on request parameters
+ * @type {Object}
+ */
+
+ if (name) {
+ const sanitizedName = _.escapeRegExp(name.trim());
+ filter['names.en'] = { $regex: new RegExp(sanitizedName, 'i') }; // Case-insensitive regex match for English name
+ }
+
+ if (anime) {
+ const sanitizedAnime = _.escapeRegExp(anime.trim());
+ filter['from.name'] = { $regex: new RegExp(sanitizedAnime, 'i') }; // Case-insensitive regex match for anime name
+ }
+
+ /**
+ * Holds the result of the random waifu retrieval.
+ * @type {Object}
+ */
+ const [result] = await Waifus.aggregate([
+ { $match: filter }, // Apply filter conditions (if any)
+ { $sample: { size: 1 } },
+ { $project: { __v: 0 } },
+ ]);
+
+ // If no fact is found, return a 404 error
+ if (!result) {
+ return next(createError(404, 'Could not find any matching waifu'));
+ }
+ /**
+ * Responds with a JSON object containing the random waifu.
+ * @type {Object}
+ * @property {Number} _id - The unique identifier of the waifu.
+ * @property {Object} names - Object containing different names for the waifu (en, jp, alt).
+ * @property {String} names.en - English name of the waifu.
+ * @property {String} names.jp - Japanese name of the waifu.
+ * @property {String} names.alt - Alternate name of the waifu.
+ * @property {Object} from - Object containing information about the origin of the waifu.
+ * @property {String} from.name - Name of the source or series.
+ * @property {String} from.type - Type of the source or series.
+ * @property {Array
} images - Array of image URLs associated with the waifu.
+ * @property {Object} statistics - Object containing various statistics related to the waifu.
+ * @property {Number} statistics.fav - Number of favorites for the waifu.
+ * @property {Number} statistics.love - Number of loves for the waifu.
+ * @property {Number} statistics.hate - Number of hates for the waifu.
+ * @property {Number} statistics.upvote - Number of upvotes for the waifu.
+ * @property {Number} statistics.downvote - Number of downvotes for the waifu.
+ */
+ res.status(200).json(result);
+
+ // Update system statistics for waifus
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { waifus: 1 } });
+ } catch (error) {
+ /**
+ * Update system statistics for failed requests
+ * @type {Object}
+ */
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ next(error);
+ }
+};
+
+export default getWaifu;
diff --git a/src/controllers/v4/interactions/angry.js b/src/controllers/v4/interactions/angry.js
new file mode 100644
index 0000000..35e8051
--- /dev/null
+++ b/src/controllers/v4/interactions/angry.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Angry from '../../../models/schemas/Angry.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Angry
+const getRandomAngry = async (req, res, next) => {
+ try {
+ const [result] = await Angry.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Angry Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { angry: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomAngry;
\ No newline at end of file
diff --git a/src/controllers/v4/interactions/baka.js b/src/controllers/v4/interactions/baka.js
new file mode 100644
index 0000000..1afa018
--- /dev/null
+++ b/src/controllers/v4/interactions/baka.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Baka from '../../../models/schemas/Baka.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Baka
+const getRandomBaka = async (req, res, next) => {
+ try {
+ const [result] = await Baka.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Baka Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { baka: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomBaka;
diff --git a/src/controllers/v4/interactions/bite.js b/src/controllers/v4/interactions/bite.js
new file mode 100644
index 0000000..591e677
--- /dev/null
+++ b/src/controllers/v4/interactions/bite.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Bite from '../../../models/schemas/Bite.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Bite
+const getRandomBite = async (req, res, next) => {
+ try {
+ const [result] = await Bite.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Bite Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bite: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomBite;
diff --git a/src/controllers/v4/interactions/blush.js b/src/controllers/v4/interactions/blush.js
new file mode 100644
index 0000000..2c698c8
--- /dev/null
+++ b/src/controllers/v4/interactions/blush.js
@@ -0,0 +1,32 @@
+
+import createError from 'http-errors';
+import Blush from '../../../models/schemas/Blush.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Blush
+const getRandomBlush = async (req, res, next) => {
+ try {
+ const [result] = await Blush.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Blush Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { blush: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomBlush;
+
diff --git a/src/controllers/v4/interactions/bonk.js b/src/controllers/v4/interactions/bonk.js
new file mode 100644
index 0000000..bcf4786
--- /dev/null
+++ b/src/controllers/v4/interactions/bonk.js
@@ -0,0 +1,32 @@
+
+import createError from 'http-errors';
+import Bonk from '../../../models/schemas/Bonk.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Bonk
+const getRandomBonk = async (req, res, next) => {
+ try {
+ const [result] = await Bonk.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Bonk Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bonk: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+
+};
+
+export default getRandomBonk;
diff --git a/src/controllers/v4/interactions/bored.js b/src/controllers/v4/interactions/bored.js
new file mode 100644
index 0000000..3879136
--- /dev/null
+++ b/src/controllers/v4/interactions/bored.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Bored from '../../../models/schemas/Bored.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Bored
+const getRandomBored = async (req, res, next) => {
+ try {
+ const [result] = await Bored.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Bored Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bored: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomBored;
diff --git a/src/controllers/v4/interactions/bully.js b/src/controllers/v4/interactions/bully.js
new file mode 100644
index 0000000..d7ea12b
--- /dev/null
+++ b/src/controllers/v4/interactions/bully.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Bully from '../../../models/schemas/Bully.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Bully
+const getRandomBully = async (req, res, next) => {
+ try {
+ const [result] = await Bully.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Bully Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bully: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomBully;
diff --git a/src/controllers/v4/interactions/bye.js b/src/controllers/v4/interactions/bye.js
new file mode 100644
index 0000000..3a6ff17
--- /dev/null
+++ b/src/controllers/v4/interactions/bye.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Bye from '../../../models/schemas/Bye.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Bye
+const getRandomBye = async (req, res, next) => {
+ try {
+ const [result] = await Bye.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Bye Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bye: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomBye;
diff --git a/src/controllers/v4/interactions/chase.js b/src/controllers/v4/interactions/chase.js
new file mode 100644
index 0000000..f2dfeea
--- /dev/null
+++ b/src/controllers/v4/interactions/chase.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Chase from '../../../models/schemas/Chase.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Chase
+const getRandomChase = async (req, res, next) => {
+ try {
+ const [result] = await Chase.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Chase Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { chase: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomChase;
diff --git a/src/controllers/v4/interactions/cheer.js b/src/controllers/v4/interactions/cheer.js
new file mode 100644
index 0000000..54c4f55
--- /dev/null
+++ b/src/controllers/v4/interactions/cheer.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Cheer from '../../../models/schemas/Cheer.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Cheer
+const getRandomCheer = async (req, res, next) => {
+ try {
+ const [result] = await Cheer.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Cheer Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cheer: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomCheer;
diff --git a/src/controllers/v4/interactions/cringe.js b/src/controllers/v4/interactions/cringe.js
new file mode 100644
index 0000000..badd781
--- /dev/null
+++ b/src/controllers/v4/interactions/cringe.js
@@ -0,0 +1,32 @@
+
+
+import createError from 'http-errors';
+import Cringe from '../../../models/schemas/Cringe.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Cringe
+const getRandomCringe = async (req, res, next) => {
+ try {
+ const [result] = await Cringe.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Cringe Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cringe: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomCringe;
diff --git a/src/controllers/v4/interactions/cry.js b/src/controllers/v4/interactions/cry.js
new file mode 100644
index 0000000..00c4861
--- /dev/null
+++ b/src/controllers/v4/interactions/cry.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Cry from '../../../models/schemas/Cry.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Cry
+const getRandomCry = async (req, res, next) => {
+ try {
+ const [result] = await Cry.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Cry Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cry: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomCry;
diff --git a/src/controllers/v4/interactions/cuddle.js b/src/controllers/v4/interactions/cuddle.js
new file mode 100644
index 0000000..36bdf52
--- /dev/null
+++ b/src/controllers/v4/interactions/cuddle.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Cuddle from '../../../models/schemas/Cuddle.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Cuddle
+const getRandomCuddle = async (req, res, next) => {
+ try {
+ const [result] = await Cuddle.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Cuddle Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { cuddle: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomCuddle;
diff --git a/src/controllers/v4/interactions/dab.js b/src/controllers/v4/interactions/dab.js
new file mode 100644
index 0000000..88f3315
--- /dev/null
+++ b/src/controllers/v4/interactions/dab.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Dab from '../../../models/schemas/Dab.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Dab
+const getRandomDab = async (req, res, next) => {
+ try {
+ const [result] = await Dab.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Dab Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { dab: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomDab;
diff --git a/src/controllers/v4/interactions/dance.js b/src/controllers/v4/interactions/dance.js
new file mode 100644
index 0000000..615a043
--- /dev/null
+++ b/src/controllers/v4/interactions/dance.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Dance from '../../../models/schemas/Dance.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Dance
+const getRandomDance = async (req, res, next) => {
+ try {
+ const [result] = await Dance.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Dance Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { dance: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomDance;
diff --git a/src/controllers/v4/interactions/die.js b/src/controllers/v4/interactions/die.js
new file mode 100644
index 0000000..e194b3e
--- /dev/null
+++ b/src/controllers/v4/interactions/die.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Die from '../../../models/schemas/Die.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Die
+const getRandomDie = async (req, res, next) => {
+ try {
+ const [result] = await Die.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Die Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { die: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomDie;
diff --git a/src/controllers/v4/interactions/disgust.js b/src/controllers/v4/interactions/disgust.js
new file mode 100644
index 0000000..6c83bb1
--- /dev/null
+++ b/src/controllers/v4/interactions/disgust.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Disgust from '../../../models/schemas/Disgust.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Disgust
+const getRandomDisgust = async (req, res, next) => {
+ try {
+ const [result] = await Disgust.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Disgust Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { disgust: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomDisgust;
diff --git a/src/controllers/v4/interactions/facepalm.js b/src/controllers/v4/interactions/facepalm.js
new file mode 100644
index 0000000..8149def
--- /dev/null
+++ b/src/controllers/v4/interactions/facepalm.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Facepalm from '../../../models/schemas/Facepalm.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Facepalm
+const getRandomFacepalm = async (req, res, next) => {
+ try {
+ const [result] = await Facepalm.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Facepalm Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { facepalm: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomFacepalm;
diff --git a/src/controllers/v4/interactions/feed.js b/src/controllers/v4/interactions/feed.js
new file mode 100644
index 0000000..6145e04
--- /dev/null
+++ b/src/controllers/v4/interactions/feed.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Feed from '../../../models/schemas/Feed.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Feed
+const getRandomFeed = async (req, res, next) => {
+ try {
+ const [result] = await Feed.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Feed Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { feed: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomFeed;
diff --git a/src/controllers/v4/interactions/glomp.js b/src/controllers/v4/interactions/glomp.js
new file mode 100644
index 0000000..3f2e32b
--- /dev/null
+++ b/src/controllers/v4/interactions/glomp.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Glomp from '../../../models/schemas/Glomp.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Glomp
+const getRandomGlomp = async (req, res, next) => {
+ try {
+ const [result] = await Glomp.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Glomp Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { glomp: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomGlomp;
diff --git a/src/controllers/v4/interactions/happy.js b/src/controllers/v4/interactions/happy.js
new file mode 100644
index 0000000..4379c45
--- /dev/null
+++ b/src/controllers/v4/interactions/happy.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Happy from '../../../models/schemas/Happy.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Happy
+const getRandomHappy = async (req, res, next) => {
+ try {
+ const [result] = await Happy.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Happy Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { happy: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomHappy;
diff --git a/src/controllers/v4/interactions/hi.js b/src/controllers/v4/interactions/hi.js
new file mode 100644
index 0000000..08ffb0f
--- /dev/null
+++ b/src/controllers/v4/interactions/hi.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Hi from '../../../models/schemas/Hi.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Hi
+const getRandomHi = async (req, res, next) => {
+ try {
+ const [result] = await Hi.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Hi Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hi: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomHi;
diff --git a/src/controllers/v4/interactions/highfive.js b/src/controllers/v4/interactions/highfive.js
new file mode 100644
index 0000000..2f19fea
--- /dev/null
+++ b/src/controllers/v4/interactions/highfive.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Highfive from '../../../models/schemas/Highfive.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Highfive
+const getRandomHighfive = async (req, res, next) => {
+ try {
+ const [result] = await Highfive.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Highfive Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { highfive: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomHighfive;
diff --git a/src/controllers/v4/interactions/hold.js b/src/controllers/v4/interactions/hold.js
new file mode 100644
index 0000000..0dddf0d
--- /dev/null
+++ b/src/controllers/v4/interactions/hold.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Hold from '../../../models/schemas/Hold.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Hold
+const getRandomHold = async (req, res, next) => {
+ try {
+ const [result] = await Hold.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Hold Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hold: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomHold;
diff --git a/src/controllers/v4/interactions/hug.js b/src/controllers/v4/interactions/hug.js
new file mode 100644
index 0000000..f619681
--- /dev/null
+++ b/src/controllers/v4/interactions/hug.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Hug from '../../../models/schemas/Hug.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Hug
+const getRandomHug = async (req, res, next) => {
+ try {
+ const [result] = await Hug.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Hug Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { hug: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomHug;
diff --git a/src/controllers/v4/interactions/kick.js b/src/controllers/v4/interactions/kick.js
new file mode 100644
index 0000000..c07b92e
--- /dev/null
+++ b/src/controllers/v4/interactions/kick.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Kick from '../../../models/schemas/Kick.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Kick
+const getRandomKick = async (req, res, next) => {
+ try {
+ const [result] = await Kick.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Kick Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kick: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomKick;
diff --git a/src/controllers/v4/interactions/kill.js b/src/controllers/v4/interactions/kill.js
new file mode 100644
index 0000000..8e40895
--- /dev/null
+++ b/src/controllers/v4/interactions/kill.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Kill from '../../../models/schemas/Kill.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Kill
+const getRandomKill = async (req, res, next) => {
+ try {
+ const [result] = await Kill.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Kill Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kill: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomKill;
diff --git a/src/controllers/v4/interactions/kiss.js b/src/controllers/v4/interactions/kiss.js
new file mode 100644
index 0000000..d2e1b2a
--- /dev/null
+++ b/src/controllers/v4/interactions/kiss.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Kissu from '../../../models/schemas/Kissu.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Kiss
+const getRandomKiss = async (req, res, next) => {
+ try {
+ const [result] = await Kissu.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Kiss Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { kissu: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomKiss;
diff --git a/src/controllers/v4/interactions/laugh.js b/src/controllers/v4/interactions/laugh.js
new file mode 100644
index 0000000..f34b771
--- /dev/null
+++ b/src/controllers/v4/interactions/laugh.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Laugh from '../../../models/schemas/Laugh.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Laugh
+const getRandomLaugh = async (req, res, next) => {
+ try {
+ const [result] = await Laugh.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Laugh Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { laugh: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomLaugh;
diff --git a/src/controllers/v4/interactions/lick.js b/src/controllers/v4/interactions/lick.js
new file mode 100644
index 0000000..9c50d21
--- /dev/null
+++ b/src/controllers/v4/interactions/lick.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Lick from '../../../models/schemas/Lick.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Lick
+const getRandomLick = async (req, res, next) => {
+ try {
+ const [result] = await Lick.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Lick Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { lick: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomLick;
diff --git a/src/controllers/v4/interactions/love.js b/src/controllers/v4/interactions/love.js
new file mode 100644
index 0000000..bf22105
--- /dev/null
+++ b/src/controllers/v4/interactions/love.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Love from '../../../models/schemas/Love.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Love
+const getRandomLove = async (req, res, next) => {
+ try {
+ const [result] = await Love.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Love Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { love: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomLove;
diff --git a/src/controllers/v4/interactions/lurk.js b/src/controllers/v4/interactions/lurk.js
new file mode 100644
index 0000000..b0ae8b5
--- /dev/null
+++ b/src/controllers/v4/interactions/lurk.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Lurk from '../../../models/schemas/Lurk.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Lurk
+const getRandomLurk = async (req, res, next) => {
+ try {
+ const [result] = await Lurk.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Lurk Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { lurk: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomLurk;
diff --git a/src/controllers/v4/interactions/midfing.js b/src/controllers/v4/interactions/midfing.js
new file mode 100644
index 0000000..2f1afa0
--- /dev/null
+++ b/src/controllers/v4/interactions/midfing.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Midfing from '../../../models/schemas/Midfing.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Midfing
+const getRandomMidfing = async (req, res, next) => {
+ try {
+ const [result] = await Midfing.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Midfing Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { midfing: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomMidfing;
diff --git a/src/controllers/v4/interactions/nervous.js b/src/controllers/v4/interactions/nervous.js
new file mode 100644
index 0000000..c3f7b6e
--- /dev/null
+++ b/src/controllers/v4/interactions/nervous.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Nervous from '../../../models/schemas/Nervous.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Nervous
+const getRandomNervous = async (req, res, next) => {
+ try {
+ const [result] = await Nervous.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Nervous Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nervous: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomNervous;
diff --git a/src/controllers/v4/interactions/nom.js b/src/controllers/v4/interactions/nom.js
new file mode 100644
index 0000000..47f04e2
--- /dev/null
+++ b/src/controllers/v4/interactions/nom.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Nom from '../../../models/schemas/Nom.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Nom
+const getRandomNom = async (req, res, next) => {
+ try {
+ const [result] = await Nom.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Nom Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nom: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomNom;
diff --git a/src/controllers/v4/interactions/nope.js b/src/controllers/v4/interactions/nope.js
new file mode 100644
index 0000000..1079cfa
--- /dev/null
+++ b/src/controllers/v4/interactions/nope.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Nope from '../../../models/schemas/Nope.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Nope
+const getRandomNope = async (req, res, next) => {
+ try {
+ const [result] = await Nope.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Nope Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nope: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomNope;
diff --git a/src/controllers/v4/interactions/nuzzle.js b/src/controllers/v4/interactions/nuzzle.js
new file mode 100644
index 0000000..85b583f
--- /dev/null
+++ b/src/controllers/v4/interactions/nuzzle.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Nuzzle from '../../../models/schemas/Nuzzle.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Nuzzle
+const getRandomNuzzle = async (req, res, next) => {
+ try {
+ const [result] = await Nuzzle.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Nuzzle Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { nuzzle: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomNuzzle;
diff --git a/src/controllers/v4/interactions/panic.js b/src/controllers/v4/interactions/panic.js
new file mode 100644
index 0000000..dc9a13e
--- /dev/null
+++ b/src/controllers/v4/interactions/panic.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Panic from '../../../models/schemas/Panic.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Panic
+const getRandomPanic = async (req, res, next) => {
+ try {
+ const [result] = await Panic.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Panic Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { panic: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomPanic;
diff --git a/src/controllers/v4/interactions/pat.js b/src/controllers/v4/interactions/pat.js
new file mode 100644
index 0000000..3295744
--- /dev/null
+++ b/src/controllers/v4/interactions/pat.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Pat from '../../../models/schemas/Pat.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Pat
+const getRandomPat = async (req, res, next) => {
+ try {
+ const [result] = await Pat.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Pat Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { pat: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomPat;
diff --git a/src/controllers/v4/interactions/peck.js b/src/controllers/v4/interactions/peck.js
new file mode 100644
index 0000000..133b904
--- /dev/null
+++ b/src/controllers/v4/interactions/peck.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Peck from '../../../models/schemas/Peck.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Peck
+const getRandomPeck = async (req, res, next) => {
+ try {
+ const [result] = await Peck.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Peck Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { peck: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomPeck;
diff --git a/src/controllers/v4/interactions/poke.js b/src/controllers/v4/interactions/poke.js
new file mode 100644
index 0000000..94e4c9d
--- /dev/null
+++ b/src/controllers/v4/interactions/poke.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Poke from '../../../models/schemas/Poke.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Poke
+const getRandomPoke = async (req, res, next) => {
+ try {
+ const [result] = await Poke.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Poke Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { poke: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomPoke;
diff --git a/src/controllers/v4/interactions/pout.js b/src/controllers/v4/interactions/pout.js
new file mode 100644
index 0000000..995232b
--- /dev/null
+++ b/src/controllers/v4/interactions/pout.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Pout from '../../../models/schemas/Pout.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Pout
+const getRandomPout = async (req, res, next) => {
+ try {
+ const [result] = await Pout.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Pout Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { pout: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomPout;
diff --git a/src/controllers/v4/interactions/punch.js b/src/controllers/v4/interactions/punch.js
new file mode 100644
index 0000000..f9f1d93
--- /dev/null
+++ b/src/controllers/v4/interactions/punch.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Punch from '../../../models/schemas/Punch.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Punch
+const getRandomPunch = async (req, res, next) => {
+ try {
+ const [result] = await Punch.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Punch Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { punch: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomPunch;
diff --git a/src/controllers/v4/interactions/run.js b/src/controllers/v4/interactions/run.js
new file mode 100644
index 0000000..3005f7a
--- /dev/null
+++ b/src/controllers/v4/interactions/run.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Run from '../../../models/schemas/Run.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Run
+const getRandomRun = async (req, res, next) => {
+ try {
+ const [result] = await Run.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Run Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { run: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomRun;
diff --git a/src/controllers/v4/interactions/sad.js b/src/controllers/v4/interactions/sad.js
new file mode 100644
index 0000000..9b2c660
--- /dev/null
+++ b/src/controllers/v4/interactions/sad.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Sad from '../../../models/schemas/Sad.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Sad
+const getRandomSad = async (req, res, next) => {
+ try {
+ const [result] = await Sad.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Sad Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sad: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomSad;
diff --git a/src/controllers/v4/interactions/shoot.js b/src/controllers/v4/interactions/shoot.js
new file mode 100644
index 0000000..de561ba
--- /dev/null
+++ b/src/controllers/v4/interactions/shoot.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Shoot from '../../../models/schemas/Shoot.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Shoot
+const getRandomShoot = async (req, res, next) => {
+ try {
+ const [result] = await Shoot.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Shoot Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { shoot: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomShoot;
diff --git a/src/controllers/v4/interactions/shrug.js b/src/controllers/v4/interactions/shrug.js
new file mode 100644
index 0000000..10dcf62
--- /dev/null
+++ b/src/controllers/v4/interactions/shrug.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Shrug from '../../../models/schemas/Shrug.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Shrug
+const getRandomShrug = async (req, res, next) => {
+ try {
+ const [result] = await Shrug.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Shrug Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { shrug: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomShrug;
diff --git a/src/controllers/v4/interactions/sip.js b/src/controllers/v4/interactions/sip.js
new file mode 100644
index 0000000..9f41a60
--- /dev/null
+++ b/src/controllers/v4/interactions/sip.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Sip from '../../../models/schemas/Sip.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Sip
+const getRandomSip = async (req, res, next) => {
+ try {
+ const [result] = await Sip.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Sip Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sip: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomSip;
diff --git a/src/controllers/v4/interactions/slap.js b/src/controllers/v4/interactions/slap.js
new file mode 100644
index 0000000..b9a51a2
--- /dev/null
+++ b/src/controllers/v4/interactions/slap.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Slap from '../../../models/schemas/Slap.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Slap
+const getRandomSlap = async (req, res, next) => {
+ try {
+ const [result] = await Slap.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Slap Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { slap: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomSlap;
diff --git a/src/controllers/v4/interactions/sleepy.js b/src/controllers/v4/interactions/sleepy.js
new file mode 100644
index 0000000..b321317
--- /dev/null
+++ b/src/controllers/v4/interactions/sleepy.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Sleepy from '../../../models/schemas/Sleepy.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Sleepy
+const getRandomSleepy = async (req, res, next) => {
+ try {
+ const [result] = await Sleepy.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Sleepy Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { sleepy: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomSleepy;
diff --git a/src/controllers/v4/interactions/smile.js b/src/controllers/v4/interactions/smile.js
new file mode 100644
index 0000000..885057a
--- /dev/null
+++ b/src/controllers/v4/interactions/smile.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Smile from '../../../models/schemas/Smile.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Smile
+const getRandomSmile = async (req, res, next) => {
+ try {
+ const [result] = await Smile.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Smile Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { smile: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomSmile;
diff --git a/src/controllers/v4/interactions/smug.js b/src/controllers/v4/interactions/smug.js
new file mode 100644
index 0000000..0f6a1f8
--- /dev/null
+++ b/src/controllers/v4/interactions/smug.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Smug from '../../../models/schemas/Smug.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Smug
+const getRandomSmug = async (req, res, next) => {
+ try {
+ const [result] = await Smug.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Smug Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { smug: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomSmug;
diff --git a/src/controllers/v4/interactions/stab.js b/src/controllers/v4/interactions/stab.js
new file mode 100644
index 0000000..742b2a1
--- /dev/null
+++ b/src/controllers/v4/interactions/stab.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Stab from '../../../models/schemas/Stab.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Stab
+const getRandomStab = async (req, res, next) => {
+ try {
+ const [result] = await Stab.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Stab Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { stab: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomStab;
diff --git a/src/controllers/v4/interactions/stare.js b/src/controllers/v4/interactions/stare.js
new file mode 100644
index 0000000..6cd83f1
--- /dev/null
+++ b/src/controllers/v4/interactions/stare.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Stare from '../../../models/schemas/Stare.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Stare
+const getRandomStare = async (req, res, next) => {
+ try {
+ const [result] = await Stare.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Stare Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { stare: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomStare;
diff --git a/src/controllers/v4/interactions/suicide.js b/src/controllers/v4/interactions/suicide.js
new file mode 100644
index 0000000..5ba6d1f
--- /dev/null
+++ b/src/controllers/v4/interactions/suicide.js
@@ -0,0 +1,34 @@
+
+
+
+
+import createError from 'http-errors';
+import Suicide from '../../../models/schemas/Suicide.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Suicide
+const getRandomSuicide = async (req, res, next) => {
+ try {
+ const [result] = await Suicide.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Suicide Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { suicide: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomSuicide;
diff --git a/src/controllers/v4/interactions/tease.js b/src/controllers/v4/interactions/tease.js
new file mode 100644
index 0000000..8939709
--- /dev/null
+++ b/src/controllers/v4/interactions/tease.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Tease from '../../../models/schemas/Tease.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Tease
+const getRandomTease = async (req, res, next) => {
+ try {
+ const [result] = await Tease.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Tease Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { tease: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomTease;
diff --git a/src/controllers/v4/interactions/think.js b/src/controllers/v4/interactions/think.js
new file mode 100644
index 0000000..5af4973
--- /dev/null
+++ b/src/controllers/v4/interactions/think.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Think from '../../../models/schemas/Think.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Think
+const getRandomThink = async (req, res, next) => {
+ try {
+ const [result] = await Think.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Think Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { think: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomThink;
diff --git a/src/controllers/v4/interactions/thumbsup.js b/src/controllers/v4/interactions/thumbsup.js
new file mode 100644
index 0000000..9131cf8
--- /dev/null
+++ b/src/controllers/v4/interactions/thumbsup.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Thumbsup from '../../../models/schemas/Thumbsup.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Thumbsup
+const getRandomThumbsup = async (req, res, next) => {
+ try {
+ const [result] = await Thumbsup.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Thumbsup Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { thumbsup: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomThumbsup;
diff --git a/src/controllers/v4/interactions/tickle.js b/src/controllers/v4/interactions/tickle.js
new file mode 100644
index 0000000..b7fee1e
--- /dev/null
+++ b/src/controllers/v4/interactions/tickle.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Tickle from '../../../models/schemas/Tickle.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Tickle
+const getRandomTickle = async (req, res, next) => {
+ try {
+ const [result] = await Tickle.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Tickle Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { tickle: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomTickle;
diff --git a/src/controllers/v4/interactions/triggered.js b/src/controllers/v4/interactions/triggered.js
new file mode 100644
index 0000000..c287eee
--- /dev/null
+++ b/src/controllers/v4/interactions/triggered.js
@@ -0,0 +1,33 @@
+
+
+
+import createError from 'http-errors';
+import Triggered from '../../../models/schemas/Triggered.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Triggered
+const getRandomTriggered = async (req, res, next) => {
+ try {
+ const [result] = await Triggered.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Triggered Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { triggered: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate(
+ { _id: 'systemstats' },
+ { $inc: { failed_requests: 1 } }
+ );
+ return next(error);
+ }
+};
+
+export default getRandomTriggered;
diff --git a/src/controllers/v4/interactions/wag.js b/src/controllers/v4/interactions/wag.js
new file mode 100644
index 0000000..6e32232
--- /dev/null
+++ b/src/controllers/v4/interactions/wag.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Wag from '../../../models/schemas/Wag.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Wag
+const getRandomWag = async (req, res, next) => {
+ try {
+ const [result] = await Wag.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Wag Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wag: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomWag;
diff --git a/src/controllers/v4/interactions/wave.js b/src/controllers/v4/interactions/wave.js
new file mode 100644
index 0000000..fb8bd0f
--- /dev/null
+++ b/src/controllers/v4/interactions/wave.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Wave from '../../../models/schemas/Wave.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Wave
+const getRandomWave = async (req, res, next) => {
+ try {
+ const [result] = await Wave.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Wave Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wave: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomWave;
diff --git a/src/controllers/v4/interactions/wink.js b/src/controllers/v4/interactions/wink.js
new file mode 100644
index 0000000..a33087e
--- /dev/null
+++ b/src/controllers/v4/interactions/wink.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Wink from '../../../models/schemas/Wink.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Wink
+const getRandomWink = async (req, res, next) => {
+ try {
+ const [result] = await Wink.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Wink Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { wink: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomWink;
diff --git a/src/controllers/v4/interactions/yes.js b/src/controllers/v4/interactions/yes.js
new file mode 100644
index 0000000..82e2047
--- /dev/null
+++ b/src/controllers/v4/interactions/yes.js
@@ -0,0 +1,27 @@
+import createError from 'http-errors';
+import Yesh from '../../../models/schemas/Yesh.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+// Get random Anime Yes
+const getRandomYes = async (req, res, next) => {
+ try {
+ const [result] = await Yesh.aggregate([
+ // Select a random document from the results
+ { $sample: { size: 1 } },
+ { $project: { __v: 0, _id: 0 } },
+ ]);
+
+ if (!result) {
+ return next(createError(404, 'Could not find any Yes Gif'));
+ }
+
+ res.status(200).json(result);
+
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { yes: 1 } });
+ } catch (error) {
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getRandomYes;
diff --git a/src/controllers/v4/internal/user.js b/src/controllers/v4/internal/user.js
new file mode 100644
index 0000000..b8a2c7c
--- /dev/null
+++ b/src/controllers/v4/internal/user.js
@@ -0,0 +1,141 @@
+import crypto from 'crypto';
+import Users from '../../../models/schemas/User.js';
+import generateToken from '../../../modules/generateToken.js';
+
+/**
+ * Fetches user profile data based on the provided user ID
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ * @returns {Object} - User profile data.
+ */
+const retrieveUserProfile = async (req, res, next) => {
+ const key = req.headers.key;
+ // Check for valid access key in headers
+ if (!key || key !== process.env.ACCESS_KEY) {
+ return res.status(401).json({
+ message: 'Unauthorized',
+ });
+ }
+ const user = await Users.findById(req.params.id);
+ if (!user) {
+ return res.status(404).json({ message: 'User not found' }); // User not found
+ }
+
+ // This will return the data however it won't be the latest one after updating the token
+ return res.status(200).json(user);
+};
+
+/**
+ * Fetches user profile data based on the provided user ID and Reset Token.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ * @returns {Object} - User profile data.
+ */
+const updateUserToken = async (req, res, next) => {
+ const key = req.headers.key;
+ // Check for valid access key in headers
+ if (!key || key !== process.env.ACCESS_KEY) {
+ return res.status(401).json({
+ message: 'Unauthorized',
+ });
+ }
+ const user = await Users.findById(req.params.id);
+ if (!user) {
+ return res.status(404).json({ message: 'User not found' }); // User not found
+ }
+
+ // Update user's token in the database
+ await Users.updateOne(
+ { _id: { $eq: req.params.id } },
+ { $set: { token: generateToken(req.params.id, process.env.HMAC_KEY) } },
+ );
+
+ // This will return the data however it won't be the latest one after updating the token
+ return res.status(200).json({
+ message: 'Token reset successfully.',
+ });
+};
+
+/**
+ * Handles user-related operations based on the HTTP method.
+ *
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ */
+const userEndpoint = async (req, res, next) => {
+ try {
+ const { body, headers, method } = req;
+ const { key } = headers;
+
+ // Check for valid access key in headers
+ if (!key || key !== process.env.ACCESS_KEY) {
+ return res.status(401).json({
+ message: 'Unauthorized',
+ });
+ }
+
+ if (method === 'POST') {
+ const { token, id } = body;
+
+ // Check for required fields in the request body
+ if (!token || !id) {
+ return res.status(400).json({
+ message: 'Token and User ID are required in the request body',
+ });
+ }
+
+ // Update user's token in the database
+ await Users.updateOne(
+ { _id: { $eq: id } },
+ { $set: { token: token } },
+ { upsert: true }, // Create the document if it doesn't exist
+ );
+
+ return res.status(200).json({
+ message: 'Token updated successfully',
+ });
+ } else if (method === 'GET') {
+ const { id, email } = headers;
+
+ // Check for required User ID in the headers
+ if (!id) {
+ return res.status(400).json({
+ message: 'User ID missing in the request body',
+ });
+ }
+
+ // Fetch user details based on the provided user ID
+ const user = await Users.findOne({ _id: { $eq: id } });
+
+ if (!user) {
+ // If user not found, create a new user with the provided ID and token
+ const newUser = {
+ _id: id,
+ email: email,
+ password: crypto.randomBytes(22).toString('base64'),
+ token: generateToken(id, process.env.HMAC_KEY),
+ // Add other fields in the "newUser" object based on your schema
+ };
+
+ await Users.create(newUser);
+
+ return res.status(201).json(newUser.token);
+ }
+
+ return res.status(200).json(user.token);
+ } else {
+ return res.status(405).json({
+ message: 'Method Not Allowed',
+ });
+ }
+ } catch (error) {
+ return next(error);
+ }
+};
+
+export { userEndpoint, retrieveUserProfile, updateUserToken };
diff --git a/src/controllers/v4/textUtilities/fact.js b/src/controllers/v4/textUtilities/fact.js
new file mode 100644
index 0000000..1892ddd
--- /dev/null
+++ b/src/controllers/v4/textUtilities/fact.js
@@ -0,0 +1,88 @@
+import createError from 'http-errors';
+import Facts from '../../../models/schemas/Fact.js';
+import tagsFilter from '../../../modules/tagsFilter.js';
+import lengthFilter from '../../../modules/lengthFilter.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Gets a random anime fact with optional length and tags filters and updates system statistics.
+ *
+ * @function
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ *
+ * @throws {Error} If there is an error during fact retrieval or database update.
+ *
+ * @returns {Object} JSON object containing the random fact.
+ * @property {String} _id - The unique identifier of the fact.
+ * @property {String} fact - The text of the anime fact.
+ * @property {Array} tags - Array of tags associated with the fact.
+ * @property {Number} length - The length of the fact.
+ *
+ * @example
+ * // Example usage in Express route handler
+ * getFact(req, res, next);
+ */
+const getFact = async (req, res, next) => {
+ try {
+ /**
+ * Extracts minLength, maxLength, and tags parameters from the request query.
+ * @type {Object}
+ */
+ const { minLength, maxLength, tags } = req.query;
+
+ /**
+ * Holds the filter object based on the optional length and tags parameters.
+ * @type {Object}
+ */
+ const filter = {};
+
+ // Apply length filter (if minLength or maxLength is provided)
+ if (minLength || maxLength) {
+ filter.length = lengthFilter(minLength, maxLength);
+ }
+
+ // Apply tags filter (if tags are provided)
+ if (tags) {
+ filter.tags = tagsFilter(tags);
+ }
+
+ /**
+ * Holds the result of the random fact retrieval.
+ * @type {Object}
+ */
+ const [result] = await Facts.aggregate([
+ { $match: filter }, // Apply filters (if any)
+ { $sample: { size: 1 } }, // Select a random document from the results
+ { $project: { __v: 0 } },
+ ]);
+
+ // If no fact is found, return a 404 error
+ if (!result) {
+ return next(createError(404, 'Could not find any matching fact'));
+ }
+
+ /**
+ * Responds with a JSON object containing the random fact.
+ * @type {Object}
+ * @property {String} _id - The unique identifier of the fact.
+ * @property {String} fact - The text of the anime fact.
+ * @property {Array} tags - Array of tags associated with the fact.
+ * @property {Number} length - The length of the fact.
+ */
+ res.status(200).json(result);
+
+ // Update system statistics for facts
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { facts: 1 } });
+ } catch (error) {
+ /**
+ * Update system statistics for failed requests
+ * @type {Object}
+ */
+ await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { failed_requests: 1 } });
+ return next(error);
+ }
+};
+
+export default getFact;
diff --git a/src/controllers/v4/textUtilities/listTags.js b/src/controllers/v4/textUtilities/listTags.js
new file mode 100644
index 0000000..1bac190
--- /dev/null
+++ b/src/controllers/v4/textUtilities/listTags.js
@@ -0,0 +1,81 @@
+import Tags from '../../../models/schemas/Tags.js';
+import parseOrder from '../../../modules/parseOrder.js';
+import Stats from '../../../models/schemas/Stat.js';
+
+/**
+ * Lists tags with optional sorting and updates system statistics.
+ *
+ * @function
+ * @param {Object} req - Express request object.
+ * @param {Object} res - Express response object.
+ * @param {Function} next - Express next middleware function.
+ *
+ * @throws {Error} If there is an error during tag listing or database update.
+ *
+ * @returns {Object} JSON object containing the sorted tags.
+ * @property {Array