@colyseus/tools 0.16.18 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +79 -53
- package/build/index.js.map +3 -3
- package/build/index.mjs +76 -44
- package/build/index.mjs.map +2 -2
- package/build/loadenv.js +5 -4
- package/build/loadenv.js.map +2 -2
- package/build/loadenv.mjs +1 -1
- package/build/loadenv.mjs.map +2 -2
- package/build/src/index.d.ts +31 -0
- package/package.json +18 -15
- package/pm2/post-deploy-agent.js +18 -46
- package/pm2/shared.js +7 -94
- package/post-deploy.js +4 -8
- package/report-stats.js +0 -56
- package/system-boot.js +0 -83
- package/build/index.d.ts +0 -20
- package/pm2/ActionMethods.js +0 -47
- /package/build/{loadenv.d.ts → src/loadenv.d.ts} +0 -0
package/build/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -25,20 +26,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
26
|
mod
|
|
26
27
|
));
|
|
27
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
30
|
-
default: () =>
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
default: () => index_default,
|
|
31
32
|
getTransport: () => getTransport,
|
|
32
33
|
listen: () => listen
|
|
33
34
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
-
var import_loadenv = require("./loadenv.
|
|
36
|
-
var import_os = __toESM(require("os"));
|
|
37
|
-
var import_fs = __toESM(require("fs"));
|
|
38
|
-
var import_net = __toESM(require("net"));
|
|
39
|
-
var import_http = __toESM(require("http"));
|
|
40
|
-
var import_cors = __toESM(require("cors"));
|
|
41
|
-
var import_express = __toESM(require("express"));
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_loadenv = require("./loadenv.ts");
|
|
37
|
+
var import_os = __toESM(require("os"), 1);
|
|
38
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
39
|
+
var import_net = __toESM(require("net"), 1);
|
|
40
|
+
var import_http = __toESM(require("http"), 1);
|
|
41
|
+
var import_cors = __toESM(require("cors"), 1);
|
|
42
|
+
var import_express = __toESM(require("express"), 1);
|
|
42
43
|
var import_core = require("@colyseus/core");
|
|
43
44
|
var import_ws_transport = require("@colyseus/ws-transport");
|
|
44
45
|
const BunWebSockets = import("@colyseus/bun-websockets");
|
|
@@ -53,13 +54,16 @@ RedisPresence.catch(() => {
|
|
|
53
54
|
const ALLOWED_KEYS = {
|
|
54
55
|
"displayLogs": "boolean",
|
|
55
56
|
"options": "object",
|
|
56
|
-
"
|
|
57
|
+
"rooms": "object",
|
|
58
|
+
"routes": "object",
|
|
57
59
|
"initializeTransport": "function",
|
|
58
60
|
"initializeExpress": "function",
|
|
59
61
|
"initializeGameServer": "function",
|
|
60
|
-
"beforeListen": "function"
|
|
62
|
+
"beforeListen": "function",
|
|
63
|
+
// deprecated options (will be removed in the next major version)
|
|
64
|
+
"getId": "function"
|
|
61
65
|
};
|
|
62
|
-
function
|
|
66
|
+
function index_default(options) {
|
|
63
67
|
for (const option in options) {
|
|
64
68
|
if (!ALLOWED_KEYS[option]) {
|
|
65
69
|
throw new Error(`\u274C Invalid option '${option}'. Allowed options are: ${Object.keys(ALLOWED_KEYS).join(", ")}`);
|
|
@@ -76,23 +80,35 @@ async function listen(options, port = Number(process.env.PORT || 2567)) {
|
|
|
76
80
|
}
|
|
77
81
|
const processNumber = Number(process.env.NODE_APP_INSTANCE || "0");
|
|
78
82
|
port += processNumber;
|
|
79
|
-
let
|
|
83
|
+
let server;
|
|
80
84
|
let displayLogs = true;
|
|
81
85
|
if (options instanceof import_core.Server) {
|
|
82
|
-
|
|
86
|
+
server = options;
|
|
87
|
+
if (process.env.COLYSEUS_CLOUD !== void 0) {
|
|
88
|
+
const isLocalDriver = import_core.matchMaker.driver instanceof import_core.LocalDriver;
|
|
89
|
+
const isLocalPresence = import_core.matchMaker.presence instanceof import_core.LocalPresence;
|
|
90
|
+
const cloudConfig = await getColyseusCloudConfig(
|
|
91
|
+
port,
|
|
92
|
+
isLocalDriver ? void 0 : import_core.matchMaker.driver,
|
|
93
|
+
isLocalPresence ? void 0 : import_core.matchMaker.presence
|
|
94
|
+
);
|
|
95
|
+
if (cloudConfig && (isLocalDriver || isLocalPresence)) {
|
|
96
|
+
await import_core.matchMaker.setup(cloudConfig.presence, cloudConfig.driver, cloudConfig.publicAddress);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
83
99
|
} else {
|
|
84
|
-
|
|
100
|
+
server = await buildServerFromOptions(options, port);
|
|
85
101
|
displayLogs = options.displayLogs;
|
|
86
|
-
await options.initializeGameServer?.(
|
|
102
|
+
await options.initializeGameServer?.(server);
|
|
87
103
|
await import_core.matchMaker.onReady;
|
|
88
104
|
await options.beforeListen?.();
|
|
89
105
|
}
|
|
90
106
|
if (process.env.COLYSEUS_CLOUD !== void 0) {
|
|
91
|
-
const socketPath = `/
|
|
107
|
+
const socketPath = `/tmp/${port}.sock`;
|
|
92
108
|
await checkInactiveSocketFile(socketPath);
|
|
93
|
-
await
|
|
109
|
+
await server.listen(socketPath);
|
|
94
110
|
} else {
|
|
95
|
-
await
|
|
111
|
+
await server.listen(port);
|
|
96
112
|
}
|
|
97
113
|
if (typeof process.send === "function") {
|
|
98
114
|
process.send("ready");
|
|
@@ -100,46 +116,22 @@ async function listen(options, port = Number(process.env.PORT || 2567)) {
|
|
|
100
116
|
if (displayLogs) {
|
|
101
117
|
import_core.logger.info(`\u2694\uFE0F Listening on http://localhost:${port}`);
|
|
102
118
|
}
|
|
103
|
-
return
|
|
119
|
+
return server;
|
|
104
120
|
}
|
|
105
121
|
async function buildServerFromOptions(options, port) {
|
|
106
122
|
const serverOptions = options.options || {};
|
|
107
123
|
options.displayLogs = options.displayLogs ?? true;
|
|
108
124
|
if (process.env.COLYSEUS_CLOUD !== void 0) {
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} catch (e) {
|
|
115
|
-
console.error(e);
|
|
116
|
-
import_core.logger.warn("");
|
|
117
|
-
import_core.logger.warn("\u274C could not initialize RedisDriver.");
|
|
118
|
-
import_core.logger.warn("\u{1F449} npm install --save @colyseus/redis-driver");
|
|
119
|
-
import_core.logger.warn("");
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (!serverOptions.presence && useRedisConfig) {
|
|
123
|
-
try {
|
|
124
|
-
const module2 = await RedisPresence;
|
|
125
|
-
serverOptions.presence = new module2.RedisPresence(process.env.REDIS_URI);
|
|
126
|
-
} catch (e) {
|
|
127
|
-
console.error(e);
|
|
128
|
-
import_core.logger.warn("");
|
|
129
|
-
import_core.logger.warn("\u274C could not initialize RedisPresence.");
|
|
130
|
-
import_core.logger.warn("\u{1F449} npm install --save @colyseus/redis-presence");
|
|
131
|
-
import_core.logger.warn("");
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (useRedisConfig) {
|
|
135
|
-
serverOptions.publicAddress = process.env.SUBDOMAIN + "." + process.env.SERVER_NAME;
|
|
136
|
-
serverOptions.publicAddress += "/" + port;
|
|
125
|
+
const cloudConfig = await getColyseusCloudConfig(port, serverOptions.driver, serverOptions.presence);
|
|
126
|
+
if (cloudConfig) {
|
|
127
|
+
serverOptions.driver = cloudConfig.driver;
|
|
128
|
+
serverOptions.presence = cloudConfig.presence;
|
|
129
|
+
serverOptions.publicAddress = cloudConfig.publicAddress;
|
|
137
130
|
}
|
|
138
131
|
}
|
|
139
|
-
|
|
140
|
-
return new import_core.Server({
|
|
132
|
+
return (0, import_core.defineServer)(options.rooms || {}, options.routes, {
|
|
141
133
|
...serverOptions,
|
|
142
|
-
transport
|
|
134
|
+
transport: await getTransport(options)
|
|
143
135
|
});
|
|
144
136
|
}
|
|
145
137
|
async function getTransport(options) {
|
|
@@ -178,6 +170,40 @@ async function getTransport(options) {
|
|
|
178
170
|
}
|
|
179
171
|
return transport;
|
|
180
172
|
}
|
|
173
|
+
async function getColyseusCloudConfig(port, currentDriver, currentPresence) {
|
|
174
|
+
const useRedisConfig = import_os.default.cpus().length > 1 || process.env.REDIS_URI !== void 0;
|
|
175
|
+
if (!useRedisConfig) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
let driver = currentDriver;
|
|
179
|
+
let presence = currentPresence;
|
|
180
|
+
const publicAddress = process.env.SUBDOMAIN + "." + process.env.SERVER_NAME + "/" + port;
|
|
181
|
+
if (!driver) {
|
|
182
|
+
try {
|
|
183
|
+
const module2 = await RedisDriver;
|
|
184
|
+
driver = new module2.RedisDriver(process.env.REDIS_URI);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
console.error(e);
|
|
187
|
+
import_core.logger.warn("");
|
|
188
|
+
import_core.logger.warn("\u274C could not initialize RedisDriver.");
|
|
189
|
+
import_core.logger.warn("\u{1F449} npm install --save @colyseus/redis-driver");
|
|
190
|
+
import_core.logger.warn("");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (!presence) {
|
|
194
|
+
try {
|
|
195
|
+
const module2 = await RedisPresence;
|
|
196
|
+
presence = new module2.RedisPresence(process.env.REDIS_URI);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
console.error(e);
|
|
199
|
+
import_core.logger.warn("");
|
|
200
|
+
import_core.logger.warn("\u274C could not initialize RedisPresence.");
|
|
201
|
+
import_core.logger.warn("\u{1F449} npm install --save @colyseus/redis-presence");
|
|
202
|
+
import_core.logger.warn("");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { driver, presence, publicAddress };
|
|
206
|
+
}
|
|
181
207
|
function checkInactiveSocketFile(sockFilePath) {
|
|
182
208
|
return new Promise((resolve, reject) => {
|
|
183
209
|
const client = import_net.default.createConnection({ path: sockFilePath }).on("connect", () => {
|
package/build/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import './loadenv.js';\nimport os from 'os';\nimport fs from \"fs\";\nimport net from \"net\";\nimport http from 'http';\nimport cors from 'cors';\nimport express from 'express';\nimport { logger, Server, ServerOptions, Transport, matchMaker } from '@colyseus/core';\nimport { WebSocketTransport } from '@colyseus/ws-transport';\n\nconst BunWebSockets = import('@colyseus/bun-websockets'); BunWebSockets.catch(() => {});\nconst RedisDriver = import('@colyseus/redis-driver'); RedisDriver.catch(() => {});\nconst RedisPresence = import('@colyseus/redis-presence'); RedisPresence.catch(() => {});\n\nexport interface ConfigOptions {\n options?: ServerOptions,\n displayLogs?: boolean,\n getId?: () => string,\n initializeTransport?: (options: any) => Transport,\n initializeExpress?: (app: express.Express) => void,\n initializeGameServer?: (app: Server) => void,\n beforeListen?: () => void,\n}\n\nconst ALLOWED_KEYS: { [key in keyof ConfigOptions]: string } = {\n 'displayLogs': \"boolean\",\n 'options': \"object\",\n 'getId': \"function\",\n 'initializeTransport': \"function\",\n 'initializeExpress': \"function\",\n 'initializeGameServer': \"function\",\n 'beforeListen': \"function\"\n};\n\nexport default function (options: ConfigOptions) {\n for (const option in options) {\n if (!ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid option '${option}'. Allowed options are: ${Object.keys(ALLOWED_KEYS).join(\", \")}`);\n }\n if(options[option] !== undefined && typeof(options[option]) !== ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid type for ${option}: please provide a ${ALLOWED_KEYS[option]} value.`);\n }\n }\n\n return options;\n}\n\n/**\n * Listen on your development environment\n * @param options Application options\n * @param port Port number to bind Colyseus + Express\n */\nexport async function listen(\n options: ConfigOptions | Server,\n port: number = Number(process.env.PORT || 2567),\n) {\n // Force 2567 port on Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n port = 2567;\n }\n\n //\n // Handling multiple processes\n // Use NODE_APP_INSTANCE to play nicely with pm2\n //\n const processNumber = Number(process.env.NODE_APP_INSTANCE || \"0\");\n port += processNumber;\n\n let gameServer: Server;\n let displayLogs = true;\n\n if (options instanceof Server) {\n gameServer = options;\n\n } else {\n gameServer = await buildServerFromOptions(options, port);\n displayLogs = options.displayLogs;\n\n await options.initializeGameServer?.(gameServer);\n await matchMaker.onReady;\n await options.beforeListen?.();\n }\n\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n // listening on socket\n const socketPath: any = `/run/colyseus/${port}.sock`;\n\n // check if .sock file is active\n // (fixes \"ADDRINUSE\" issue when restarting the server)\n await checkInactiveSocketFile(socketPath);\n\n await gameServer.listen(socketPath);\n\n } else {\n // listening on port\n await gameServer.listen(port);\n }\n\n // notify process manager (production)\n if (typeof(process.send) === \"function\") {\n process.send('ready');\n }\n\n if (displayLogs) {\n logger.info(`\u2694\uFE0F Listening on http://localhost:${port}`);\n }\n\n return gameServer;\n}\n\nasync function buildServerFromOptions(options: ConfigOptions, port: number) {\n const serverOptions = options.options || {};\n options.displayLogs = options.displayLogs ?? true;\n\n // automatically configure for production under Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n\n // special configuration is required when using multiple processes\n const useRedisConfig = (os.cpus().length > 1) || (process.env.REDIS_URI !== undefined);\n\n if (!serverOptions.driver && useRedisConfig) {\n try {\n const module = await RedisDriver;\n serverOptions.driver = new module.RedisDriver(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisDriver.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-driver\");\n logger.warn(\"\");\n }\n }\n\n if (!serverOptions.presence && useRedisConfig) {\n try {\n const module = await RedisPresence;\n serverOptions.presence = new module.RedisPresence(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisPresence.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-presence\");\n logger.warn(\"\");\n }\n }\n\n if (useRedisConfig) {\n // force \"publicAddress\" when more than 1 process is available\n serverOptions.publicAddress = process.env.SUBDOMAIN + \".\" + process.env.SERVER_NAME;\n\n // nginx is responsible for forwarding /{port}/ to this process\n serverOptions.publicAddress += \"/\" + port;\n }\n }\n\n const transport = await getTransport(options);\n return new Server({\n ...serverOptions,\n transport,\n });\n}\n\nexport async function getTransport(options: ConfigOptions) {\n let transport: Transport;\n\n if (!options.initializeTransport) {\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n // @colyseus/bun-websockets\n BunWebSockets.catch(() => {\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize BunWebSockets.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/bun-websockets\");\n logger.warn(\"\");\n })\n const module = await BunWebSockets;\n options.initializeTransport = (options: any) => new module.BunWebSockets(options);\n\n } else {\n // use WebSocketTransport by default\n options.initializeTransport = (options: any) => new WebSocketTransport(options);\n }\n }\n\n let app: express.Express | undefined = express();\n let server = http.createServer(app);\n\n transport = await options.initializeTransport({ server, app });\n\n //\n // TODO: refactor me!\n // BunWebSockets: There's no need to instantiate \"app\" and \"server\" above\n //\n if (transport['expressApp']) {\n app = transport['expressApp'];\n }\n\n if (app) {\n // Enable CORS\n app.use(cors({ origin: true, credentials: true, }));\n\n if (options.initializeExpress) {\n await options.initializeExpress(app);\n }\n\n // health check for load balancers\n app.get(\"/__healthcheck\", (req, res) => {\n res.status(200).end();\n });\n\n if (options.displayLogs) {\n logger.info(\"\u2705 Express initialized\");\n }\n }\n\n return transport;\n}\n\n/**\n * Check if a socket file is active and remove it if it's not.\n */\nfunction checkInactiveSocketFile(sockFilePath: string) {\n return new Promise((resolve, reject) => {\n const client = net.createConnection({ path: sockFilePath })\n .on('connect', () => {\n // socket file is active, close the connection\n client.end();\n throw new Error(`EADDRINUSE: Already listening on '${sockFilePath}'`);\n })\n .on('error', () => {\n // socket file is inactive, remove it\n fs.unlink(sockFilePath, () => resolve(true));\n });\n });\n}"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import './loadenv.ts';\nimport os from 'os';\nimport fs from \"fs\";\nimport net from \"net\";\nimport http from 'http';\nimport cors from 'cors';\nimport express from 'express';\nimport {\n type ServerOptions,\n type SDKTypes,\n type Router,\n logger,\n Server,\n Transport,\n matchMaker,\n RegisteredHandler,\n defineServer,\n LocalDriver,\n LocalPresence\n} from '@colyseus/core';\nimport { WebSocketTransport } from '@colyseus/ws-transport';\n\nconst BunWebSockets = import('@colyseus/bun-websockets'); BunWebSockets.catch(() => {});\nconst RedisDriver = import('@colyseus/redis-driver'); RedisDriver.catch(() => {});\nconst RedisPresence = import('@colyseus/redis-presence'); RedisPresence.catch(() => {});\n\nexport interface ConfigOptions<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n> extends SDKTypes<RoomTypes, Routes> {\n options?: ServerOptions,\n displayLogs?: boolean,\n rooms?: RoomTypes,\n routes?: Routes,\n initializeTransport?: (options: any) => Transport,\n initializeExpress?: (app: express.Express) => void,\n initializeGameServer?: (app: Server) => void,\n beforeListen?: () => void,\n /**\n * @deprecated getId() has no effect anymore.\n */\n getId?: () => string,\n}\n\nconst ALLOWED_KEYS: { [key in keyof Partial<ConfigOptions>]: string } = {\n 'displayLogs': \"boolean\",\n 'options': \"object\",\n 'rooms': \"object\",\n 'routes': \"object\",\n 'initializeTransport': \"function\",\n 'initializeExpress': \"function\",\n 'initializeGameServer': \"function\",\n 'beforeListen': \"function\",\n // deprecated options (will be removed in the next major version)\n 'getId': \"function\",\n};\n\nexport default function <\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(options: Omit<ConfigOptions<RoomTypes, Routes>, '~rooms' | '~routes'>) {\n for (const option in options) {\n if (!ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid option '${option}'. Allowed options are: ${Object.keys(ALLOWED_KEYS).join(\", \")}`);\n }\n if(options[option] !== undefined && typeof(options[option]) !== ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid type for ${option}: please provide a ${ALLOWED_KEYS[option]} value.`);\n }\n }\n return options as ConfigOptions<RoomTypes, Routes>;\n}\n\n/**\n * Expose server instance and listen on the port specified\n * @param options Application options\n * @param port Port number to bind Colyseus + Express\n */\nexport async function listen<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(\n options: ConfigOptions<RoomTypes, Routes>,\n port?: number,\n): Promise<Server<RoomTypes, Routes>>;\n\n/**\n * Expose server instance and listen on the port specified\n * @param server Server instance\n * @param port Port number to bind Colyseus + Express\n */\nexport async function listen<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(\n server: Server<RoomTypes, Routes>,\n port?: number,\n): Promise<Server<RoomTypes, Routes>>;\n\nexport async function listen<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(\n options: ConfigOptions<RoomTypes, Routes> | Server<RoomTypes, Routes>,\n port: number = Number(process.env.PORT || 2567),\n) {\n // Force 2567 port on Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n port = 2567;\n }\n\n //\n // Handling multiple processes\n // Use NODE_APP_INSTANCE to play nicely with pm2\n //\n const processNumber = Number(process.env.NODE_APP_INSTANCE || \"0\");\n port += processNumber;\n\n let server: Server<RoomTypes, Routes>;\n let displayLogs = true;\n\n if (options instanceof Server) {\n server = options;\n\n // automatically configure for production under Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n // check if local driver/presence are being used (defaults)\n const isLocalDriver = matchMaker.driver instanceof LocalDriver;\n const isLocalPresence = matchMaker.presence instanceof LocalPresence;\n\n const cloudConfig = await getColyseusCloudConfig(\n port,\n isLocalDriver ? undefined : matchMaker.driver,\n isLocalPresence ? undefined : matchMaker.presence,\n );\n\n // re-setup matchMaker with Redis driver/presence\n if (cloudConfig && (isLocalDriver || isLocalPresence)) {\n await matchMaker.setup(cloudConfig.presence, cloudConfig.driver, cloudConfig.publicAddress);\n }\n }\n\n } else {\n server = await buildServerFromOptions<RoomTypes, Routes>(options, port);\n displayLogs = options.displayLogs;\n\n await options.initializeGameServer?.(server);\n await matchMaker.onReady;\n await options.beforeListen?.();\n }\n\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n // listening on socket\n // const socketPath: any = `/run/colyseus/${port}.sock`;\n const socketPath: any = `/tmp/${port}.sock`;\n\n // check if .sock file is active\n // (fixes \"ADDRINUSE\" issue when restarting the server)\n await checkInactiveSocketFile(socketPath);\n\n await server.listen(socketPath);\n\n } else {\n // listening on port\n await server.listen(port);\n }\n\n // notify process manager (production)\n if (typeof(process.send) === \"function\") {\n process.send('ready');\n }\n\n if (displayLogs) {\n logger.info(`\u2694\uFE0F Listening on http://localhost:${port}`);\n }\n\n return server;\n}\n\nasync function buildServerFromOptions<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(options: ConfigOptions<RoomTypes, Routes>, port: number) {\n const serverOptions = options.options || {};\n options.displayLogs = options.displayLogs ?? true;\n\n // automatically configure for production under Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n const cloudConfig = await getColyseusCloudConfig(port, serverOptions.driver, serverOptions.presence);\n if (cloudConfig) {\n serverOptions.driver = cloudConfig.driver;\n serverOptions.presence = cloudConfig.presence;\n serverOptions.publicAddress = cloudConfig.publicAddress;\n }\n }\n\n return defineServer<RoomTypes, Routes>(options.rooms || {} as RoomTypes, options.routes, {\n ...serverOptions,\n transport: await getTransport(options),\n });\n}\n\nexport async function getTransport(options: ConfigOptions) {\n let transport: Transport;\n\n if (!options.initializeTransport) {\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n // @colyseus/bun-websockets\n BunWebSockets.catch(() => {\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize BunWebSockets.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/bun-websockets\");\n logger.warn(\"\");\n })\n const module = await BunWebSockets;\n options.initializeTransport = (options: any) => new module.BunWebSockets(options);\n\n } else {\n // use WebSocketTransport by default\n options.initializeTransport = (options: any) => new WebSocketTransport(options);\n }\n }\n\n let app: express.Express | undefined = express();\n let server = http.createServer(app);\n\n transport = await options.initializeTransport({ server, app });\n\n //\n // TODO: refactor me!\n // BunWebSockets: There's no need to instantiate \"app\" and \"server\" above\n //\n if (transport['expressApp']) {\n app = transport['expressApp'];\n }\n\n if (app) {\n // Enable CORS\n app.use(cors({ origin: true, credentials: true, }));\n\n if (options.initializeExpress) {\n await options.initializeExpress(app);\n }\n\n // health check for load balancers\n app.get(\"/__healthcheck\", (req, res) => {\n res.status(200).end();\n });\n\n if (options.displayLogs) {\n logger.info(\"\u2705 Express initialized\");\n }\n }\n\n return transport;\n}\n\n/**\n * Configure Redis driver/presence for Colyseus Cloud when needed.\n * Returns configured driver, presence, and publicAddress.\n */\nasync function getColyseusCloudConfig(port: number, currentDriver?: any, currentPresence?: any) {\n const useRedisConfig = (os.cpus().length > 1) || (process.env.REDIS_URI !== undefined);\n\n if (!useRedisConfig) {\n return null;\n }\n\n let driver = currentDriver;\n let presence = currentPresence;\n const publicAddress = process.env.SUBDOMAIN + \".\" + process.env.SERVER_NAME + \"/\" + port;\n\n if (!driver) {\n try {\n const module = await RedisDriver;\n driver = new module.RedisDriver(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisDriver.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-driver\");\n logger.warn(\"\");\n }\n }\n\n if (!presence) {\n try {\n const module = await RedisPresence;\n presence = new module.RedisPresence(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisPresence.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-presence\");\n logger.warn(\"\");\n }\n }\n\n return { driver, presence, publicAddress };\n}\n\n/**\n * Check if a socket file is active and remove it if it's not.\n */\nfunction checkInactiveSocketFile(sockFilePath: string) {\n return new Promise((resolve, reject) => {\n const client = net.createConnection({ path: sockFilePath })\n .on('connect', () => {\n // socket file is active, close the connection\n client.end();\n throw new Error(`EADDRINUSE: Already listening on '${sockFilePath}'`);\n })\n .on('error', () => {\n // socket file is inactive, remove it\n fs.unlink(sockFilePath, () => resolve(true));\n });\n });\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAO;AACP,gBAAe;AACf,gBAAe;AACf,iBAAgB;AAChB,kBAAiB;AACjB,kBAAiB;AACjB,qBAAoB;AACpB,kBAYO;AACP,0BAAmC;AAEnC,MAAM,gBAAgB,OAAO,0BAA0B;AAAG,cAAc,MAAM,MAAM;AAAC,CAAC;AACtF,MAAM,cAAc,OAAO,wBAAwB;AAAG,YAAY,MAAM,MAAM;AAAC,CAAC;AAChF,MAAM,gBAAgB,OAAO,0BAA0B;AAAG,cAAc,MAAM,MAAM;AAAC,CAAC;AAoBtF,MAAM,eAAkE;AAAA,EACtE,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AAAA,EACT,UAAU;AAAA,EACV,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,gBAAgB;AAAA;AAAA,EAEhB,SAAS;AACX;AAEe,SAAR,cAGL,SAAuE;AACvE,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC,aAAa,MAAM,GAAG;AACzB,YAAM,IAAI,MAAM,0BAAqB,MAAM,2BAA2B,OAAO,KAAK,YAAY,EAAE,KAAK,IAAI,CAAC,EAAE;AAAA,IAC9G;AACA,QAAG,QAAQ,MAAM,MAAM,UA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cAAsB;AACrD,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,WAAAM,QAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC,EACvD,GAAG,WAAW,MAAM;AAEnB,aAAO,IAAI;AACX,YAAM,IAAI,MAAM,qCAAqC,YAAY,GAAG;AAAA,IACtE,CAAC,EACA,GAAG,SAAS,MAAM;AAEjB,gBAAAC,QAAG,OAAO,cAAc,MAAM,QAAQ,IAAI,CAAC;AAAA,IAC7C,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
|
+
"names": ["module", "options", "express", "http", "cors", "os", "net", "fs"]
|
|
7
7
|
}
|
package/build/index.mjs
CHANGED
|
@@ -6,7 +6,14 @@ import net from "net";
|
|
|
6
6
|
import http from "http";
|
|
7
7
|
import cors from "cors";
|
|
8
8
|
import express from "express";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
logger,
|
|
11
|
+
Server,
|
|
12
|
+
matchMaker,
|
|
13
|
+
defineServer,
|
|
14
|
+
LocalDriver,
|
|
15
|
+
LocalPresence
|
|
16
|
+
} from "@colyseus/core";
|
|
10
17
|
import { WebSocketTransport } from "@colyseus/ws-transport";
|
|
11
18
|
var BunWebSockets = import("@colyseus/bun-websockets");
|
|
12
19
|
BunWebSockets.catch(() => {
|
|
@@ -20,13 +27,16 @@ RedisPresence.catch(() => {
|
|
|
20
27
|
var ALLOWED_KEYS = {
|
|
21
28
|
"displayLogs": "boolean",
|
|
22
29
|
"options": "object",
|
|
23
|
-
"
|
|
30
|
+
"rooms": "object",
|
|
31
|
+
"routes": "object",
|
|
24
32
|
"initializeTransport": "function",
|
|
25
33
|
"initializeExpress": "function",
|
|
26
34
|
"initializeGameServer": "function",
|
|
27
|
-
"beforeListen": "function"
|
|
35
|
+
"beforeListen": "function",
|
|
36
|
+
// deprecated options (will be removed in the next major version)
|
|
37
|
+
"getId": "function"
|
|
28
38
|
};
|
|
29
|
-
function
|
|
39
|
+
function index_default(options) {
|
|
30
40
|
for (const option in options) {
|
|
31
41
|
if (!ALLOWED_KEYS[option]) {
|
|
32
42
|
throw new Error(`\u274C Invalid option '${option}'. Allowed options are: ${Object.keys(ALLOWED_KEYS).join(", ")}`);
|
|
@@ -43,23 +53,35 @@ async function listen(options, port = Number(process.env.PORT || 2567)) {
|
|
|
43
53
|
}
|
|
44
54
|
const processNumber = Number(process.env.NODE_APP_INSTANCE || "0");
|
|
45
55
|
port += processNumber;
|
|
46
|
-
let
|
|
56
|
+
let server;
|
|
47
57
|
let displayLogs = true;
|
|
48
58
|
if (options instanceof Server) {
|
|
49
|
-
|
|
59
|
+
server = options;
|
|
60
|
+
if (process.env.COLYSEUS_CLOUD !== void 0) {
|
|
61
|
+
const isLocalDriver = matchMaker.driver instanceof LocalDriver;
|
|
62
|
+
const isLocalPresence = matchMaker.presence instanceof LocalPresence;
|
|
63
|
+
const cloudConfig = await getColyseusCloudConfig(
|
|
64
|
+
port,
|
|
65
|
+
isLocalDriver ? void 0 : matchMaker.driver,
|
|
66
|
+
isLocalPresence ? void 0 : matchMaker.presence
|
|
67
|
+
);
|
|
68
|
+
if (cloudConfig && (isLocalDriver || isLocalPresence)) {
|
|
69
|
+
await matchMaker.setup(cloudConfig.presence, cloudConfig.driver, cloudConfig.publicAddress);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
50
72
|
} else {
|
|
51
|
-
|
|
73
|
+
server = await buildServerFromOptions(options, port);
|
|
52
74
|
displayLogs = options.displayLogs;
|
|
53
|
-
await options.initializeGameServer?.(
|
|
75
|
+
await options.initializeGameServer?.(server);
|
|
54
76
|
await matchMaker.onReady;
|
|
55
77
|
await options.beforeListen?.();
|
|
56
78
|
}
|
|
57
79
|
if (process.env.COLYSEUS_CLOUD !== void 0) {
|
|
58
|
-
const socketPath = `/
|
|
80
|
+
const socketPath = `/tmp/${port}.sock`;
|
|
59
81
|
await checkInactiveSocketFile(socketPath);
|
|
60
|
-
await
|
|
82
|
+
await server.listen(socketPath);
|
|
61
83
|
} else {
|
|
62
|
-
await
|
|
84
|
+
await server.listen(port);
|
|
63
85
|
}
|
|
64
86
|
if (typeof process.send === "function") {
|
|
65
87
|
process.send("ready");
|
|
@@ -67,46 +89,22 @@ async function listen(options, port = Number(process.env.PORT || 2567)) {
|
|
|
67
89
|
if (displayLogs) {
|
|
68
90
|
logger.info(`\u2694\uFE0F Listening on http://localhost:${port}`);
|
|
69
91
|
}
|
|
70
|
-
return
|
|
92
|
+
return server;
|
|
71
93
|
}
|
|
72
94
|
async function buildServerFromOptions(options, port) {
|
|
73
95
|
const serverOptions = options.options || {};
|
|
74
96
|
options.displayLogs = options.displayLogs ?? true;
|
|
75
97
|
if (process.env.COLYSEUS_CLOUD !== void 0) {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} catch (e) {
|
|
82
|
-
console.error(e);
|
|
83
|
-
logger.warn("");
|
|
84
|
-
logger.warn("\u274C could not initialize RedisDriver.");
|
|
85
|
-
logger.warn("\u{1F449} npm install --save @colyseus/redis-driver");
|
|
86
|
-
logger.warn("");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (!serverOptions.presence && useRedisConfig) {
|
|
90
|
-
try {
|
|
91
|
-
const module = await RedisPresence;
|
|
92
|
-
serverOptions.presence = new module.RedisPresence(process.env.REDIS_URI);
|
|
93
|
-
} catch (e) {
|
|
94
|
-
console.error(e);
|
|
95
|
-
logger.warn("");
|
|
96
|
-
logger.warn("\u274C could not initialize RedisPresence.");
|
|
97
|
-
logger.warn("\u{1F449} npm install --save @colyseus/redis-presence");
|
|
98
|
-
logger.warn("");
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (useRedisConfig) {
|
|
102
|
-
serverOptions.publicAddress = process.env.SUBDOMAIN + "." + process.env.SERVER_NAME;
|
|
103
|
-
serverOptions.publicAddress += "/" + port;
|
|
98
|
+
const cloudConfig = await getColyseusCloudConfig(port, serverOptions.driver, serverOptions.presence);
|
|
99
|
+
if (cloudConfig) {
|
|
100
|
+
serverOptions.driver = cloudConfig.driver;
|
|
101
|
+
serverOptions.presence = cloudConfig.presence;
|
|
102
|
+
serverOptions.publicAddress = cloudConfig.publicAddress;
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
|
-
|
|
107
|
-
return new Server({
|
|
105
|
+
return defineServer(options.rooms || {}, options.routes, {
|
|
108
106
|
...serverOptions,
|
|
109
|
-
transport
|
|
107
|
+
transport: await getTransport(options)
|
|
110
108
|
});
|
|
111
109
|
}
|
|
112
110
|
async function getTransport(options) {
|
|
@@ -145,6 +143,40 @@ async function getTransport(options) {
|
|
|
145
143
|
}
|
|
146
144
|
return transport;
|
|
147
145
|
}
|
|
146
|
+
async function getColyseusCloudConfig(port, currentDriver, currentPresence) {
|
|
147
|
+
const useRedisConfig = os.cpus().length > 1 || process.env.REDIS_URI !== void 0;
|
|
148
|
+
if (!useRedisConfig) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
let driver = currentDriver;
|
|
152
|
+
let presence = currentPresence;
|
|
153
|
+
const publicAddress = process.env.SUBDOMAIN + "." + process.env.SERVER_NAME + "/" + port;
|
|
154
|
+
if (!driver) {
|
|
155
|
+
try {
|
|
156
|
+
const module = await RedisDriver;
|
|
157
|
+
driver = new module.RedisDriver(process.env.REDIS_URI);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.error(e);
|
|
160
|
+
logger.warn("");
|
|
161
|
+
logger.warn("\u274C could not initialize RedisDriver.");
|
|
162
|
+
logger.warn("\u{1F449} npm install --save @colyseus/redis-driver");
|
|
163
|
+
logger.warn("");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!presence) {
|
|
167
|
+
try {
|
|
168
|
+
const module = await RedisPresence;
|
|
169
|
+
presence = new module.RedisPresence(process.env.REDIS_URI);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
console.error(e);
|
|
172
|
+
logger.warn("");
|
|
173
|
+
logger.warn("\u274C could not initialize RedisPresence.");
|
|
174
|
+
logger.warn("\u{1F449} npm install --save @colyseus/redis-presence");
|
|
175
|
+
logger.warn("");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return { driver, presence, publicAddress };
|
|
179
|
+
}
|
|
148
180
|
function checkInactiveSocketFile(sockFilePath) {
|
|
149
181
|
return new Promise((resolve, reject) => {
|
|
150
182
|
const client = net.createConnection({ path: sockFilePath }).on("connect", () => {
|
|
@@ -156,7 +188,7 @@ function checkInactiveSocketFile(sockFilePath) {
|
|
|
156
188
|
});
|
|
157
189
|
}
|
|
158
190
|
export {
|
|
159
|
-
|
|
191
|
+
index_default as default,
|
|
160
192
|
getTransport,
|
|
161
193
|
listen
|
|
162
194
|
};
|
package/build/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import './loadenv.js';\nimport os from 'os';\nimport fs from \"fs\";\nimport net from \"net\";\nimport http from 'http';\nimport cors from 'cors';\nimport express from 'express';\nimport { logger, Server, ServerOptions, Transport, matchMaker } from '@colyseus/core';\nimport { WebSocketTransport } from '@colyseus/ws-transport';\n\nconst BunWebSockets = import('@colyseus/bun-websockets'); BunWebSockets.catch(() => {});\nconst RedisDriver = import('@colyseus/redis-driver'); RedisDriver.catch(() => {});\nconst RedisPresence = import('@colyseus/redis-presence'); RedisPresence.catch(() => {});\n\nexport interface ConfigOptions {\n options?: ServerOptions,\n displayLogs?: boolean,\n getId?: () => string,\n initializeTransport?: (options: any) => Transport,\n initializeExpress?: (app: express.Express) => void,\n initializeGameServer?: (app: Server) => void,\n beforeListen?: () => void,\n}\n\nconst ALLOWED_KEYS: { [key in keyof ConfigOptions]: string } = {\n 'displayLogs': \"boolean\",\n 'options': \"object\",\n 'getId': \"function\",\n 'initializeTransport': \"function\",\n 'initializeExpress': \"function\",\n 'initializeGameServer': \"function\",\n 'beforeListen': \"function\"\n};\n\nexport default function (options: ConfigOptions) {\n for (const option in options) {\n if (!ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid option '${option}'. Allowed options are: ${Object.keys(ALLOWED_KEYS).join(\", \")}`);\n }\n if(options[option] !== undefined && typeof(options[option]) !== ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid type for ${option}: please provide a ${ALLOWED_KEYS[option]} value.`);\n }\n }\n\n return options;\n}\n\n/**\n * Listen on your development environment\n * @param options Application options\n * @param port Port number to bind Colyseus + Express\n */\nexport async function listen(\n options: ConfigOptions | Server,\n port: number = Number(process.env.PORT || 2567),\n) {\n // Force 2567 port on Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n port = 2567;\n }\n\n //\n // Handling multiple processes\n // Use NODE_APP_INSTANCE to play nicely with pm2\n //\n const processNumber = Number(process.env.NODE_APP_INSTANCE || \"0\");\n port += processNumber;\n\n let gameServer: Server;\n let displayLogs = true;\n\n if (options instanceof Server) {\n gameServer = options;\n\n } else {\n gameServer = await buildServerFromOptions(options, port);\n displayLogs = options.displayLogs;\n\n await options.initializeGameServer?.(gameServer);\n await matchMaker.onReady;\n await options.beforeListen?.();\n }\n\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n // listening on socket\n const socketPath: any = `/run/colyseus/${port}.sock`;\n\n // check if .sock file is active\n // (fixes \"ADDRINUSE\" issue when restarting the server)\n await checkInactiveSocketFile(socketPath);\n\n await gameServer.listen(socketPath);\n\n } else {\n // listening on port\n await gameServer.listen(port);\n }\n\n // notify process manager (production)\n if (typeof(process.send) === \"function\") {\n process.send('ready');\n }\n\n if (displayLogs) {\n logger.info(`\u2694\uFE0F Listening on http://localhost:${port}`);\n }\n\n return gameServer;\n}\n\nasync function buildServerFromOptions(options: ConfigOptions, port: number) {\n const serverOptions = options.options || {};\n options.displayLogs = options.displayLogs ?? true;\n\n // automatically configure for production under Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n\n // special configuration is required when using multiple processes\n const useRedisConfig = (os.cpus().length > 1) || (process.env.REDIS_URI !== undefined);\n\n if (!serverOptions.driver && useRedisConfig) {\n try {\n const module = await RedisDriver;\n serverOptions.driver = new module.RedisDriver(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisDriver.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-driver\");\n logger.warn(\"\");\n }\n }\n\n if (!serverOptions.presence && useRedisConfig) {\n try {\n const module = await RedisPresence;\n serverOptions.presence = new module.RedisPresence(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisPresence.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-presence\");\n logger.warn(\"\");\n }\n }\n\n if (useRedisConfig) {\n // force \"publicAddress\" when more than 1 process is available\n serverOptions.publicAddress = process.env.SUBDOMAIN + \".\" + process.env.SERVER_NAME;\n\n // nginx is responsible for forwarding /{port}/ to this process\n serverOptions.publicAddress += \"/\" + port;\n }\n }\n\n const transport = await getTransport(options);\n return new Server({\n ...serverOptions,\n transport,\n });\n}\n\nexport async function getTransport(options: ConfigOptions) {\n let transport: Transport;\n\n if (!options.initializeTransport) {\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n // @colyseus/bun-websockets\n BunWebSockets.catch(() => {\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize BunWebSockets.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/bun-websockets\");\n logger.warn(\"\");\n })\n const module = await BunWebSockets;\n options.initializeTransport = (options: any) => new module.BunWebSockets(options);\n\n } else {\n // use WebSocketTransport by default\n options.initializeTransport = (options: any) => new WebSocketTransport(options);\n }\n }\n\n let app: express.Express | undefined = express();\n let server = http.createServer(app);\n\n transport = await options.initializeTransport({ server, app });\n\n //\n // TODO: refactor me!\n // BunWebSockets: There's no need to instantiate \"app\" and \"server\" above\n //\n if (transport['expressApp']) {\n app = transport['expressApp'];\n }\n\n if (app) {\n // Enable CORS\n app.use(cors({ origin: true, credentials: true, }));\n\n if (options.initializeExpress) {\n await options.initializeExpress(app);\n }\n\n // health check for load balancers\n app.get(\"/__healthcheck\", (req, res) => {\n res.status(200).end();\n });\n\n if (options.displayLogs) {\n logger.info(\"\u2705 Express initialized\");\n }\n }\n\n return transport;\n}\n\n/**\n * Check if a socket file is active and remove it if it's not.\n */\nfunction checkInactiveSocketFile(sockFilePath: string) {\n return new Promise((resolve, reject) => {\n const client = net.createConnection({ path: sockFilePath })\n .on('connect', () => {\n // socket file is active, close the connection\n client.end();\n throw new Error(`EADDRINUSE: Already listening on '${sockFilePath}'`);\n })\n .on('error', () => {\n // socket file is inactive, remove it\n fs.unlink(sockFilePath, () => resolve(true));\n });\n });\n}"],
|
|
5
|
-
"mappings": ";AAAA,OAAO;AACP,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB,
|
|
4
|
+
"sourcesContent": ["import './loadenv.ts';\nimport os from 'os';\nimport fs from \"fs\";\nimport net from \"net\";\nimport http from 'http';\nimport cors from 'cors';\nimport express from 'express';\nimport {\n type ServerOptions,\n type SDKTypes,\n type Router,\n logger,\n Server,\n Transport,\n matchMaker,\n RegisteredHandler,\n defineServer,\n LocalDriver,\n LocalPresence\n} from '@colyseus/core';\nimport { WebSocketTransport } from '@colyseus/ws-transport';\n\nconst BunWebSockets = import('@colyseus/bun-websockets'); BunWebSockets.catch(() => {});\nconst RedisDriver = import('@colyseus/redis-driver'); RedisDriver.catch(() => {});\nconst RedisPresence = import('@colyseus/redis-presence'); RedisPresence.catch(() => {});\n\nexport interface ConfigOptions<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n> extends SDKTypes<RoomTypes, Routes> {\n options?: ServerOptions,\n displayLogs?: boolean,\n rooms?: RoomTypes,\n routes?: Routes,\n initializeTransport?: (options: any) => Transport,\n initializeExpress?: (app: express.Express) => void,\n initializeGameServer?: (app: Server) => void,\n beforeListen?: () => void,\n /**\n * @deprecated getId() has no effect anymore.\n */\n getId?: () => string,\n}\n\nconst ALLOWED_KEYS: { [key in keyof Partial<ConfigOptions>]: string } = {\n 'displayLogs': \"boolean\",\n 'options': \"object\",\n 'rooms': \"object\",\n 'routes': \"object\",\n 'initializeTransport': \"function\",\n 'initializeExpress': \"function\",\n 'initializeGameServer': \"function\",\n 'beforeListen': \"function\",\n // deprecated options (will be removed in the next major version)\n 'getId': \"function\",\n};\n\nexport default function <\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(options: Omit<ConfigOptions<RoomTypes, Routes>, '~rooms' | '~routes'>) {\n for (const option in options) {\n if (!ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid option '${option}'. Allowed options are: ${Object.keys(ALLOWED_KEYS).join(\", \")}`);\n }\n if(options[option] !== undefined && typeof(options[option]) !== ALLOWED_KEYS[option]) {\n throw new Error(`\u274C Invalid type for ${option}: please provide a ${ALLOWED_KEYS[option]} value.`);\n }\n }\n return options as ConfigOptions<RoomTypes, Routes>;\n}\n\n/**\n * Expose server instance and listen on the port specified\n * @param options Application options\n * @param port Port number to bind Colyseus + Express\n */\nexport async function listen<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(\n options: ConfigOptions<RoomTypes, Routes>,\n port?: number,\n): Promise<Server<RoomTypes, Routes>>;\n\n/**\n * Expose server instance and listen on the port specified\n * @param server Server instance\n * @param port Port number to bind Colyseus + Express\n */\nexport async function listen<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(\n server: Server<RoomTypes, Routes>,\n port?: number,\n): Promise<Server<RoomTypes, Routes>>;\n\nexport async function listen<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(\n options: ConfigOptions<RoomTypes, Routes> | Server<RoomTypes, Routes>,\n port: number = Number(process.env.PORT || 2567),\n) {\n // Force 2567 port on Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n port = 2567;\n }\n\n //\n // Handling multiple processes\n // Use NODE_APP_INSTANCE to play nicely with pm2\n //\n const processNumber = Number(process.env.NODE_APP_INSTANCE || \"0\");\n port += processNumber;\n\n let server: Server<RoomTypes, Routes>;\n let displayLogs = true;\n\n if (options instanceof Server) {\n server = options;\n\n // automatically configure for production under Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n // check if local driver/presence are being used (defaults)\n const isLocalDriver = matchMaker.driver instanceof LocalDriver;\n const isLocalPresence = matchMaker.presence instanceof LocalPresence;\n\n const cloudConfig = await getColyseusCloudConfig(\n port,\n isLocalDriver ? undefined : matchMaker.driver,\n isLocalPresence ? undefined : matchMaker.presence,\n );\n\n // re-setup matchMaker with Redis driver/presence\n if (cloudConfig && (isLocalDriver || isLocalPresence)) {\n await matchMaker.setup(cloudConfig.presence, cloudConfig.driver, cloudConfig.publicAddress);\n }\n }\n\n } else {\n server = await buildServerFromOptions<RoomTypes, Routes>(options, port);\n displayLogs = options.displayLogs;\n\n await options.initializeGameServer?.(server);\n await matchMaker.onReady;\n await options.beforeListen?.();\n }\n\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n // listening on socket\n // const socketPath: any = `/run/colyseus/${port}.sock`;\n const socketPath: any = `/tmp/${port}.sock`;\n\n // check if .sock file is active\n // (fixes \"ADDRINUSE\" issue when restarting the server)\n await checkInactiveSocketFile(socketPath);\n\n await server.listen(socketPath);\n\n } else {\n // listening on port\n await server.listen(port);\n }\n\n // notify process manager (production)\n if (typeof(process.send) === \"function\") {\n process.send('ready');\n }\n\n if (displayLogs) {\n logger.info(`\u2694\uFE0F Listening on http://localhost:${port}`);\n }\n\n return server;\n}\n\nasync function buildServerFromOptions<\n RoomTypes extends Record<string, RegisteredHandler> = any,\n Routes extends Router = any\n>(options: ConfigOptions<RoomTypes, Routes>, port: number) {\n const serverOptions = options.options || {};\n options.displayLogs = options.displayLogs ?? true;\n\n // automatically configure for production under Colyseus Cloud\n if (process.env.COLYSEUS_CLOUD !== undefined) {\n const cloudConfig = await getColyseusCloudConfig(port, serverOptions.driver, serverOptions.presence);\n if (cloudConfig) {\n serverOptions.driver = cloudConfig.driver;\n serverOptions.presence = cloudConfig.presence;\n serverOptions.publicAddress = cloudConfig.publicAddress;\n }\n }\n\n return defineServer<RoomTypes, Routes>(options.rooms || {} as RoomTypes, options.routes, {\n ...serverOptions,\n transport: await getTransport(options),\n });\n}\n\nexport async function getTransport(options: ConfigOptions) {\n let transport: Transport;\n\n if (!options.initializeTransport) {\n // @ts-ignore\n if (typeof Bun !== \"undefined\") {\n // @colyseus/bun-websockets\n BunWebSockets.catch(() => {\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize BunWebSockets.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/bun-websockets\");\n logger.warn(\"\");\n })\n const module = await BunWebSockets;\n options.initializeTransport = (options: any) => new module.BunWebSockets(options);\n\n } else {\n // use WebSocketTransport by default\n options.initializeTransport = (options: any) => new WebSocketTransport(options);\n }\n }\n\n let app: express.Express | undefined = express();\n let server = http.createServer(app);\n\n transport = await options.initializeTransport({ server, app });\n\n //\n // TODO: refactor me!\n // BunWebSockets: There's no need to instantiate \"app\" and \"server\" above\n //\n if (transport['expressApp']) {\n app = transport['expressApp'];\n }\n\n if (app) {\n // Enable CORS\n app.use(cors({ origin: true, credentials: true, }));\n\n if (options.initializeExpress) {\n await options.initializeExpress(app);\n }\n\n // health check for load balancers\n app.get(\"/__healthcheck\", (req, res) => {\n res.status(200).end();\n });\n\n if (options.displayLogs) {\n logger.info(\"\u2705 Express initialized\");\n }\n }\n\n return transport;\n}\n\n/**\n * Configure Redis driver/presence for Colyseus Cloud when needed.\n * Returns configured driver, presence, and publicAddress.\n */\nasync function getColyseusCloudConfig(port: number, currentDriver?: any, currentPresence?: any) {\n const useRedisConfig = (os.cpus().length > 1) || (process.env.REDIS_URI !== undefined);\n\n if (!useRedisConfig) {\n return null;\n }\n\n let driver = currentDriver;\n let presence = currentPresence;\n const publicAddress = process.env.SUBDOMAIN + \".\" + process.env.SERVER_NAME + \"/\" + port;\n\n if (!driver) {\n try {\n const module = await RedisDriver;\n driver = new module.RedisDriver(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisDriver.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-driver\");\n logger.warn(\"\");\n }\n }\n\n if (!presence) {\n try {\n const module = await RedisPresence;\n presence = new module.RedisPresence(process.env.REDIS_URI);\n } catch (e) {\n console.error(e);\n logger.warn(\"\");\n logger.warn(\"\u274C could not initialize RedisPresence.\");\n logger.warn(\"\uD83D\uDC49 npm install --save @colyseus/redis-presence\");\n logger.warn(\"\");\n }\n }\n\n return { driver, presence, publicAddress };\n}\n\n/**\n * Check if a socket file is active and remove it if it's not.\n */\nfunction checkInactiveSocketFile(sockFilePath: string) {\n return new Promise((resolve, reject) => {\n const client = net.createConnection({ path: sockFilePath })\n .on('connect', () => {\n // socket file is active, close the connection\n client.end();\n throw new Error(`EADDRINUSE: Already listening on '${sockFilePath}'`);\n })\n .on('error', () => {\n // socket file is inactive, remove it\n fs.unlink(sockFilePath, () => resolve(true));\n });\n });\n}"],
|
|
5
|
+
"mappings": ";AAAA,OAAO;AACP,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,aAAa;AACpB;AAAA,EAIE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AAEnC,IAAM,gBAAgB,OAAO,0BAA0B;AAAG,cAAc,MAAM,MAAM;AAAC,CAAC;AACtF,IAAM,cAAc,OAAO,wBAAwB;AA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AAC;AACf,aAAO,KAAK,EAAE;AACd,aAAO,KAAK,0CAAqC;AACjD,aAAO,KAAK,qDAA8C;AAC1D,aAAO,KAAK,EAAE;AAAA,IAChB;AAAA,EACF;AAEA,MAAI,CAAC,UAAU;AACb,QAAI;AACF,YAAM,SAAS,MAAM;AACrB,iBAAW,IAAI,OAAO,cAAc,QAAQ,IAAI,SAAS;AAAA,IAC3D,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AACf,aAAO,KAAK,EAAE;AACd,aAAO,KAAK,4CAAuC;AACnD,aAAO,KAAK,uDAAgD;AAC5D,aAAO,KAAK,EAAE;AAAA,IAChB;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,UAAU,cAAc;AAC3C;AAKA,SAAS,wBAAwB,cAAsB;AACrD,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC,EACvD,GAAG,WAAW,MAAM;AAEnB,aAAO,IAAI;AACX,YAAM,IAAI,MAAM,qCAAqC,YAAY,GAAG;AAAA,IACtE,CAAC,EACA,GAAG,SAAS,MAAM;AAEjB,SAAG,OAAO,cAAc,MAAM,QAAQ,IAAI,CAAC;AAAA,IAC7C,CAAC;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": ["options"]
|
|
7
7
|
}
|
package/build/loadenv.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,9 +21,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
22
|
mod
|
|
22
23
|
));
|
|
23
|
-
var import_fs = __toESM(require("fs"));
|
|
24
|
-
var import_path = __toESM(require("path"));
|
|
25
|
-
var import_dotenv = __toESM(require("dotenv"));
|
|
24
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
25
|
+
var import_path = __toESM(require("path"), 1);
|
|
26
|
+
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
26
27
|
function getEnvFromArgv() {
|
|
27
28
|
const envIndex = process.argv.indexOf("--env");
|
|
28
29
|
return envIndex !== -1 ? process.argv[envIndex + 1] : void 0;
|
|
@@ -39,7 +40,7 @@ function loadEnvFile(envFileOptions, log = "none") {
|
|
|
39
40
|
if (envFilename.startsWith("/")) {
|
|
40
41
|
envPaths.push(envFilename);
|
|
41
42
|
} else {
|
|
42
|
-
envPaths.push(import_path.default.resolve(import_path.default.dirname(require?.main?.filename || process.cwd()), "..", envFilename));
|
|
43
|
+
envPaths.push(import_path.default.resolve(import_path.default.dirname(typeof require !== "undefined" && require?.main?.filename || process.cwd()), "..", envFilename));
|
|
43
44
|
envPaths.push(import_path.default.resolve(process.cwd(), envFilename));
|
|
44
45
|
}
|
|
45
46
|
});
|
package/build/loadenv.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/loadenv.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport dotenv from 'dotenv';\n\nfunction getEnvFromArgv() {\n const envIndex = process.argv.indexOf(\"--env\");\n return (envIndex !== -1) ? process.argv[envIndex + 1] : undefined;\n}\n\nfunction getNodeEnv() {\n return process.env.NODE_ENV || getEnvFromArgv() || \"development\";\n}\n\nfunction getRegion() {\n // EU, NA, AS, AF, AU, SA, UNKNOWN\n return (process.env.REGION || \"unknown\").toLowerCase();\n}\n\nfunction loadEnvFile(envFileOptions: string[], log: 'none' | 'success' | 'both' = 'none') {\n const envPaths = [];\n envFileOptions.forEach((envFilename) => {\n if (envFilename.startsWith(\"/\")) {\n envPaths.push(envFilename);\n } else {\n envPaths.push(path.resolve(path.dirname(require?.main?.filename || process.cwd()), \"..\", envFilename));\n envPaths.push(path.resolve(process.cwd(), envFilename));\n }\n });\n\n // return the first .env path found\n const envPath = envPaths.find((envPath) => fs.existsSync(envPath));\n\n if (envPath) {\n dotenv.config({ path: envPath });\n\n if (log !== \"none\") {\n console.info(`\u2705 ${path.basename(envPath)} loaded.`);\n }\n\n } else if (log === \"both\") {\n console.info(`\u2139\uFE0F optional .env file not found: ${envFileOptions.join(\", \")}`);\n }\n}\n\n// reload /etc/environment, if exists\nif (fs.existsSync(\"/etc/environment\")) {\n dotenv.config({ path: \"/etc/environment\", override: true })\n}\n\n// load .env.cloud defined on admin panel\nif (process.env.COLYSEUS_CLOUD !== undefined) {\n const cloudEnvFileNames = [\".env.cloud\"];\n\n // prepend .env.cloud file from APP_ROOT_PATH\n if (process.env.APP_ROOT_PATH) {\n cloudEnvFileNames.unshift(`${process.env.APP_ROOT_PATH}${(process.env.APP_ROOT_PATH.endsWith(\"/\") ? \"\" : \"/\")}.env.cloud`);\n }\n\n loadEnvFile(cloudEnvFileNames);\n}\n\n// (overrides previous env configs)\nloadEnvFile([`.env.${getNodeEnv()}`, `.env`], 'both');\n\nif (process.env.REGION !== undefined) {\n loadEnvFile([`.env.${getRegion()}.${getNodeEnv()}`], 'success');\n}"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport dotenv from 'dotenv';\n\nfunction getEnvFromArgv() {\n const envIndex = process.argv.indexOf(\"--env\");\n return (envIndex !== -1) ? process.argv[envIndex + 1] : undefined;\n}\n\nfunction getNodeEnv() {\n return process.env.NODE_ENV || getEnvFromArgv() || \"development\";\n}\n\nfunction getRegion() {\n // EU, NA, AS, AF, AU, SA, UNKNOWN\n return (process.env.REGION || \"unknown\").toLowerCase();\n}\n\nfunction loadEnvFile(envFileOptions: string[], log: 'none' | 'success' | 'both' = 'none') {\n const envPaths = [];\n envFileOptions.forEach((envFilename) => {\n if (envFilename.startsWith(\"/\")) {\n envPaths.push(envFilename);\n } else {\n envPaths.push(path.resolve(path.dirname(typeof(require) !== \"undefined\" && require?.main?.filename || process.cwd()), \"..\", envFilename));\n envPaths.push(path.resolve(process.cwd(), envFilename));\n }\n });\n\n // return the first .env path found\n const envPath = envPaths.find((envPath) => fs.existsSync(envPath));\n\n if (envPath) {\n dotenv.config({ path: envPath });\n\n if (log !== \"none\") {\n console.info(`\u2705 ${path.basename(envPath)} loaded.`);\n }\n\n } else if (log === \"both\") {\n console.info(`\u2139\uFE0F optional .env file not found: ${envFileOptions.join(\", \")}`);\n }\n}\n\n// reload /etc/environment, if exists\nif (fs.existsSync(\"/etc/environment\")) {\n dotenv.config({ path: \"/etc/environment\", override: true })\n}\n\n// load .env.cloud defined on admin panel\nif (process.env.COLYSEUS_CLOUD !== undefined) {\n const cloudEnvFileNames = [\".env.cloud\"];\n\n // prepend .env.cloud file from APP_ROOT_PATH\n if (process.env.APP_ROOT_PATH) {\n cloudEnvFileNames.unshift(`${process.env.APP_ROOT_PATH}${(process.env.APP_ROOT_PATH.endsWith(\"/\") ? \"\" : \"/\")}.env.cloud`);\n }\n\n loadEnvFile(cloudEnvFileNames);\n}\n\n// (overrides previous env configs)\nloadEnvFile([`.env.${getNodeEnv()}`, `.env`], 'both');\n\nif (process.env.REGION !== undefined) {\n loadEnvFile([`.env.${getRegion()}.${getNodeEnv()}`], 'success');\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAe;AACf,kBAAiB;AACjB,oBAAmB;AAEnB,SAAS,iBAAiB;AACxB,QAAM,WAAW,QAAQ,KAAK,QAAQ,OAAO;AAC7C,SAAQ,aAAa,KAAM,QAAQ,KAAK,WAAW,CAAC,IAAI;AAC1D;AAEA,SAAS,aAAa;AACpB,SAAO,QAAQ,IAAI,YAAY,eAAe,KAAK;AACrD;AAEA,SAAS,YAAY;AAEnB,UAAQ,QAAQ,IAAI,UAAU,WAAW,YAAY;AACvD;AAEA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W,QAAW;AACpC,cAAY,CAAC,QAAQ,UAAU,CAAC,IAAI,WAAW,CAAC,EAAE,GAAG,SAAS;AAChE;",
|
|
6
6
|
"names": ["path", "envPath", "fs", "dotenv"]
|
|
7
7
|
}
|
package/build/loadenv.mjs
CHANGED
|
@@ -25,7 +25,7 @@ function loadEnvFile(envFileOptions, log = "none") {
|
|
|
25
25
|
if (envFilename.startsWith("/")) {
|
|
26
26
|
envPaths.push(envFilename);
|
|
27
27
|
} else {
|
|
28
|
-
envPaths.push(path.resolve(path.dirname(__require?.main?.filename || process.cwd()), "..", envFilename));
|
|
28
|
+
envPaths.push(path.resolve(path.dirname(typeof __require !== "undefined" && __require?.main?.filename || process.cwd()), "..", envFilename));
|
|
29
29
|
envPaths.push(path.resolve(process.cwd(), envFilename));
|
|
30
30
|
}
|
|
31
31
|
});
|
package/build/loadenv.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/loadenv.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport dotenv from 'dotenv';\n\nfunction getEnvFromArgv() {\n const envIndex = process.argv.indexOf(\"--env\");\n return (envIndex !== -1) ? process.argv[envIndex + 1] : undefined;\n}\n\nfunction getNodeEnv() {\n return process.env.NODE_ENV || getEnvFromArgv() || \"development\";\n}\n\nfunction getRegion() {\n // EU, NA, AS, AF, AU, SA, UNKNOWN\n return (process.env.REGION || \"unknown\").toLowerCase();\n}\n\nfunction loadEnvFile(envFileOptions: string[], log: 'none' | 'success' | 'both' = 'none') {\n const envPaths = [];\n envFileOptions.forEach((envFilename) => {\n if (envFilename.startsWith(\"/\")) {\n envPaths.push(envFilename);\n } else {\n envPaths.push(path.resolve(path.dirname(require?.main?.filename || process.cwd()), \"..\", envFilename));\n envPaths.push(path.resolve(process.cwd(), envFilename));\n }\n });\n\n // return the first .env path found\n const envPath = envPaths.find((envPath) => fs.existsSync(envPath));\n\n if (envPath) {\n dotenv.config({ path: envPath });\n\n if (log !== \"none\") {\n console.info(`\u2705 ${path.basename(envPath)} loaded.`);\n }\n\n } else if (log === \"both\") {\n console.info(`\u2139\uFE0F optional .env file not found: ${envFileOptions.join(\", \")}`);\n }\n}\n\n// reload /etc/environment, if exists\nif (fs.existsSync(\"/etc/environment\")) {\n dotenv.config({ path: \"/etc/environment\", override: true })\n}\n\n// load .env.cloud defined on admin panel\nif (process.env.COLYSEUS_CLOUD !== undefined) {\n const cloudEnvFileNames = [\".env.cloud\"];\n\n // prepend .env.cloud file from APP_ROOT_PATH\n if (process.env.APP_ROOT_PATH) {\n cloudEnvFileNames.unshift(`${process.env.APP_ROOT_PATH}${(process.env.APP_ROOT_PATH.endsWith(\"/\") ? \"\" : \"/\")}.env.cloud`);\n }\n\n loadEnvFile(cloudEnvFileNames);\n}\n\n// (overrides previous env configs)\nloadEnvFile([`.env.${getNodeEnv()}`, `.env`], 'both');\n\nif (process.env.REGION !== undefined) {\n loadEnvFile([`.env.${getRegion()}.${getNodeEnv()}`], 'success');\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AAEnB,SAAS,iBAAiB;AACxB,QAAM,WAAW,QAAQ,KAAK,QAAQ,OAAO;AAC7C,SAAQ,aAAa,KAAM,QAAQ,KAAK,WAAW,CAAC,IAAI;AAC1D;AAEA,SAAS,aAAa;AACpB,SAAO,QAAQ,IAAI,YAAY,eAAe,KAAK;AACrD;AAEA,SAAS,YAAY;AAEnB,UAAQ,QAAQ,IAAI,UAAU,WAAW,YAAY;AACvD;AAEA,SAAS,YAAY,gBAA0B,MAAoC,QAAQ;AACvF,QAAM,WAAW,CAAC;AAClB,iBAAe,QAAQ,CAAC,gBAAgB;AACtC,QAAI,YAAY,WAAW,GAAG,GAAG;AAC/B,eAAS,KAAK,WAAW;AAAA,IAC3B,OAAO;AACL,eAAS,KAAK,KAAK,QAAQ,KAAK,QAAQ,WAAS,MAAM,YAAY,QAAQ,IAAI,CAAC,GAAG,MAAM,WAAW,CAAC;
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport dotenv from 'dotenv';\n\nfunction getEnvFromArgv() {\n const envIndex = process.argv.indexOf(\"--env\");\n return (envIndex !== -1) ? process.argv[envIndex + 1] : undefined;\n}\n\nfunction getNodeEnv() {\n return process.env.NODE_ENV || getEnvFromArgv() || \"development\";\n}\n\nfunction getRegion() {\n // EU, NA, AS, AF, AU, SA, UNKNOWN\n return (process.env.REGION || \"unknown\").toLowerCase();\n}\n\nfunction loadEnvFile(envFileOptions: string[], log: 'none' | 'success' | 'both' = 'none') {\n const envPaths = [];\n envFileOptions.forEach((envFilename) => {\n if (envFilename.startsWith(\"/\")) {\n envPaths.push(envFilename);\n } else {\n envPaths.push(path.resolve(path.dirname(typeof(require) !== \"undefined\" && require?.main?.filename || process.cwd()), \"..\", envFilename));\n envPaths.push(path.resolve(process.cwd(), envFilename));\n }\n });\n\n // return the first .env path found\n const envPath = envPaths.find((envPath) => fs.existsSync(envPath));\n\n if (envPath) {\n dotenv.config({ path: envPath });\n\n if (log !== \"none\") {\n console.info(`\u2705 ${path.basename(envPath)} loaded.`);\n }\n\n } else if (log === \"both\") {\n console.info(`\u2139\uFE0F optional .env file not found: ${envFileOptions.join(\", \")}`);\n }\n}\n\n// reload /etc/environment, if exists\nif (fs.existsSync(\"/etc/environment\")) {\n dotenv.config({ path: \"/etc/environment\", override: true })\n}\n\n// load .env.cloud defined on admin panel\nif (process.env.COLYSEUS_CLOUD !== undefined) {\n const cloudEnvFileNames = [\".env.cloud\"];\n\n // prepend .env.cloud file from APP_ROOT_PATH\n if (process.env.APP_ROOT_PATH) {\n cloudEnvFileNames.unshift(`${process.env.APP_ROOT_PATH}${(process.env.APP_ROOT_PATH.endsWith(\"/\") ? \"\" : \"/\")}.env.cloud`);\n }\n\n loadEnvFile(cloudEnvFileNames);\n}\n\n// (over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