Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for running on all interfaces - required for hosting on docker. #27

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ module.exports = async (Client) => {
});

if(!isCustomInstance) {
app.listen({port: Client.port}, (err) => {
const host = Client.runOnAllInterfaces ? '0.0.0.0' : 'localhost';
app.listen({port: Client.port, host: host }, (err) => {
Client.emit('debug', "[DEBUG] API Online on port " + Client.port);

Client.readySince = Date.now();
Expand Down
7 changes: 7 additions & 0 deletions src/application/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const User = require("../structures/User");
* @param {boolean} options.cacheRoles whether to cache roles or not
* @param {boolean} options.useMongooseCache whether to use the mongoose cache or not
* @param {number} options.customCacheCooldown the custom cache cooldown
* @param {boolean} options.runOnAllInterfaces whether to run the application on all interfaces or not - needed for docker
* @param {*|null} options.apiInstance if you want to use your own express or fastify instance
* @return {Application} The application
*/
Expand Down Expand Up @@ -110,6 +111,12 @@ class Application extends EventEmitter {
*/
this.customCacheCooldown = options?.customCacheCooldown ?? 10 * 60 * 1000;

/**
* whether to run the application on all interfaces or not - needed for docker
* @type {boolean}
*/
this.runOnAllInterfaces = options?.runOnAllInterfaces ?? false;

/**
* if you want to use your own express or fastify instance
* @type {*|null}
Expand Down
6 changes: 6 additions & 0 deletions typings/application/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export = Application;
* @param {boolean} options.cacheRoles whether to cache roles or not
* @param {boolean} options.useMongooseCache whether to use the mongoose cache or not
* @param {number} options.customCacheCooldown the custom cache cooldown
* @param {boolean} options.runOnAllInterfaces whether to run the application on all interfaces or not - needed for docker
* @param {*|null} options.apiInstance if you want to use your own express or fastify instance
* @return {Application} The application
*/
Expand Down Expand Up @@ -90,6 +91,11 @@ declare class Application extends EventEmitter {
* @type {*|number}
*/
customCacheCooldown: any | number;
/**
* whether to run the application on all interfaces or not - needed for docker
* @type {boolean}
*/
runOnAllInterfaces: boolean;
/**
* if you want to use your own express or fastify instance
* @type {*|null}
Expand Down