arkos 1.4.0-canary.36 → 1.4.0-canary.37

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.
@@ -69,8 +69,8 @@ async function initApp(arkosConfig = {}) {
69
69
  sheu_1.default.ready(message.replace("{{server}}", `${(0, text_helpers_1.capitalize)(process.env.NODE_ENV || "development")} server`));
70
70
  if (networkHost && portAndHost.host === "0.0.0.0")
71
71
  sheu_1.default.ready(message
72
- .replace("{{server}}", `Network ${process.env.NODE_ENV || "development"} server`)
73
- .replace(host, networkHost));
72
+ .replace(host, networkHost)
73
+ .replace("{{server}}", `Network server`));
74
74
  if (exports._arkosConfig?.swagger?.mode)
75
75
  sheu_1.default.ready(`${message.replace("{{server}}", "Documentation")}${exports._arkosConfig?.swagger?.endpoint || "/api/docs"}`);
76
76
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;;;;;AA6JA,kGAIC;AAOD,wCAEC;AAED,sCAEC;AAEgB,0BAAO;AA7KxB,+BAAkC;AAElC,wFAAyD;AACzD,gDAAwB;AACxB,wDAAgC;AAChC,+DAA0D;AAC1D,uGAA4E;AAC5E,yCAAoE;AACpE,+DAAuE;AACvE,6CAAqE;AAErE,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACtC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO;IAE1C,cAAI,CAAC,KAAK,CAAC,0CAA0C,EAAE;QACrD,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AA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{ IncomingMessage, Server, ServerResponse } from \"http\";\nimport AppError from \"./modules/error-handler/utils/app-error\";\nimport { Express } from \"express\";\nimport { bootstrap } from \"./app\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport http from \"http\";\nimport sheu from \"./utils/sheu\";\nimport { capitalize } from \"./utils/helpers/text.helpers\";\nimport portAndHostAllocator from \"./utils/features/port-and-host-allocator\";\nimport { killDevelopmentServerChildProcess } from \"./utils/cli/dev\";\nimport { killServerChildProcess } from \"./utils/cli/utils/cli.helpers\";\nimport { killProductionServerChildProcess } from \"./utils/cli/start\";\n\nprocess.on(\"uncaughtException\", (err) => {\n if (err.message.includes(\"EPIPE\")) return;\n\n sheu.error(\"\\nUNCAUGHT EXCEPTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n\n console.error(err.name, err.message);\n console.error(err);\n process.exit(1);\n});\n\nlet server: Server<typeof IncomingMessage, typeof ServerResponse>;\nlet _app: Express;\n\nexport let _arkosConfig: ArkosConfig & { available?: boolean } = {\n welcomeMessage:\n \"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com\",\n port: Number(process.env.CLI_PORT) || Number(process.env.PORT) || 8000,\n host:\n process.env.CLI_HOST ||\n process.env.HOST ||\n (process.env.ARKOS_BUILD !== \"true\" ? \"0.0.0.0\" : \"127.0.0.1\"),\n fileUpload: {\n baseUploadDir: \"uploads\",\n baseRoute: \"/api/uploads\",\n },\n routers: {\n strict: false,\n },\n available: false,\n debugging: {\n requests: {\n level: 1,\n },\n },\n};\n\n/**\n * Initializes the application server.\n *\n * This function starts the server by listening on a specified port.\n * The port is determined by the following order of precedence:\n * 1. The `port` argument passed to the function.\n * 2. Defaults to `8000` if neither is provided.\n *\n * @param {ArkosConfig} arkosConfig - initial configs for the api ( authentication, port).\n * @returns {Promise<Express>} This function returns the Express App after all middlewares configurations.\n * You can prevent it from listen py passing port as undefined\n *\n */\nasync function initApp(\n arkosConfig: ArkosConfig = {}\n): Promise<Express | undefined> {\n try {\n _arkosConfig.available = true;\n\n const portAndHost = await portAndHostAllocator.getHostAndAvailablePort(\n process.env,\n arkosConfig\n );\n\n let networkHost = portAndHostAllocator.getFirstNonLocalIp();\n\n _arkosConfig = deepmerge(_arkosConfig, arkosConfig);\n\n _app = await bootstrap(_arkosConfig);\n const time = new Date().toTimeString().split(\" \")[0];\n\n if (\n (\"port\" in arkosConfig && arkosConfig?.port !== undefined) ||\n !(\"port\" in arkosConfig)\n ) {\n server = http.createServer(_app);\n\n if (_arkosConfig?.configureServer)\n await _arkosConfig.configureServer(server);\n\n server.listen(\n Number(portAndHost?.port),\n portAndHost.host! === \"localhost\" ? \"127.0.0.1\" : portAndHost.host!,\n () => {\n const host =\n portAndHost?.host === \"0.0.0.0\" ? \"localhost\" : portAndHost?.host;\n const message = `${sheu.gray(time)} {{server}} waiting on http://${host}:${portAndHost?.port}`;\n\n sheu.ready(\n message.replace(\n \"{{server}}\",\n `${capitalize(process.env.NODE_ENV || \"development\")} server`\n )\n );\n if (networkHost && portAndHost.host === \"0.0.0.0\")\n sheu.ready(\n message\n .replace(\n \"{{server}}\",\n `Network ${process.env.NODE_ENV || \"development\"} server`\n )\n .replace(host, networkHost)\n );\n if (_arkosConfig?.swagger?.mode)\n sheu.ready(\n `${message.replace(\"{{server}}\", \"Documentation\")}${_arkosConfig?.swagger?.endpoint || \"/api/docs\"}`\n );\n }\n );\n } else {\n sheu.warn(\n `${sheu.gray(time)} Port set to undefined, hence no internal http server was setup.`\n );\n }\n\n return _app;\n } catch (err: any) {\n sheu.error(\n err?.message || \"Something went wrong while starting your application!\"\n );\n console.error(err);\n killDevelopmentServerChildProcess?.();\n killServerChildProcess?.();\n killProductionServerChildProcess?.();\n }\n}\n\nprocess.on(\"unhandledRejection\", (err: AppError) => {\n sheu.error(\"\\nUNHANDLED REJECTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n console.error(err.name, err.message);\n console.error(err);\n server?.close(() => {\n process.exit(1);\n });\n});\n\n/**\n * Terminates the current running express application, server and process.\n *\n * @returns {void}\n */\nexport function terminateApplicationRunningProcessAndServer(): void {\n server?.close(() => {\n process.exit(1);\n });\n}\n\n/**\n * Gives access to the underlying current configurations being used by **Arkos** by default and also passed through `arkos.init()`\n *\n * @returns {ArkosConfig}\n */\nexport function getArkosConfig(): ArkosConfig {\n return _arkosConfig;\n}\n\nexport function getExpressApp() {\n return _app;\n}\n\nexport { server, initApp };\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;;;;;AA0JA,kGAIC;AAOD,wCAEC;AAED,sCAEC;AAEgB,0BAAO;AA1KxB,+BAAkC;AAElC,wFAAyD;AACzD,gDAAwB;AACxB,wDAAgC;AAChC,+DAA0D;AAC1D,uGAA4E;AAC5E,yCAAoE;AACpE,+DAAuE;AACvE,6CAAqE;AAErE,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACtC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO;IAE1C,cAAI,CAAC,KAAK,CAAC,0CAA0C,EAAE;QACrD,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IAEH,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,IAAI,MAA6D,CAAC;AAClE,IAAI,IAAa,CAAC;AAEP,QAAA,YAAY,GAA0C;IAC/D,cAAc,EACZ,6FAA6F;IAC/F,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO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AAK,CACR,GAAG,EAAE,OAAO,IAAI,uDAAuD,CACxE,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,IAAA,uCAAiC,CAAA,EAAE,EAAE,CAAC;QACtC,IAAA,oCAAsB,CAAA,EAAE,EAAE,CAAC;QAC3B,IAAA,wCAAgC,CAAA,EAAE,EAAE,CAAC;IACvC,CAAC;AACH,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,GAAa,EAAE,EAAE;IACjD,cAAI,CAAC,KAAK,CAAC,2CAA2C,EAAE;QACtD,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAOH,SAAgB,2CAA2C;IACzD,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAOD,SAAgB,cAAc;IAC5B,OAAO,oBAAY,CAAC;AACtB,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { IncomingMessage, Server, ServerResponse } from \"http\";\nimport AppError from \"./modules/error-handler/utils/app-error\";\nimport { Express } from \"express\";\nimport { bootstrap } from \"./app\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport http from \"http\";\nimport sheu from \"./utils/sheu\";\nimport { capitalize } from \"./utils/helpers/text.helpers\";\nimport portAndHostAllocator from \"./utils/features/port-and-host-allocator\";\nimport { killDevelopmentServerChildProcess } from \"./utils/cli/dev\";\nimport { killServerChildProcess } from \"./utils/cli/utils/cli.helpers\";\nimport { killProductionServerChildProcess } from \"./utils/cli/start\";\n\nprocess.on(\"uncaughtException\", (err) => {\n if (err.message.includes(\"EPIPE\")) return;\n\n sheu.error(\"\\nUNCAUGHT EXCEPTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n\n console.error(err.name, err.message);\n console.error(err);\n process.exit(1);\n});\n\nlet server: Server<typeof IncomingMessage, typeof ServerResponse>;\nlet _app: Express;\n\nexport let _arkosConfig: ArkosConfig & { available?: boolean } = {\n welcomeMessage:\n \"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com\",\n port: Number(process.env.CLI_PORT) || Number(process.env.PORT) || 8000,\n host:\n process.env.CLI_HOST ||\n process.env.HOST ||\n (process.env.ARKOS_BUILD !== \"true\" ? \"0.0.0.0\" : \"127.0.0.1\"),\n fileUpload: {\n baseUploadDir: \"uploads\",\n baseRoute: \"/api/uploads\",\n },\n routers: {\n strict: false,\n },\n available: false,\n debugging: {\n requests: {\n level: 1,\n },\n },\n};\n\n/**\n * Initializes the application server.\n *\n * This function starts the server by listening on a specified port.\n * The port is determined by the following order of precedence:\n * 1. The `port` argument passed to the function.\n * 2. Defaults to `8000` if neither is provided.\n *\n * @param {ArkosConfig} arkosConfig - initial configs for the api ( authentication, port).\n * @returns {Promise<Express>} This function returns the Express App after all middlewares configurations.\n * You can prevent it from listen py passing port as undefined\n *\n */\nasync function initApp(\n arkosConfig: ArkosConfig = {}\n): Promise<Express | undefined> {\n try {\n _arkosConfig.available = true;\n\n const portAndHost = await portAndHostAllocator.getHostAndAvailablePort(\n process.env,\n arkosConfig\n );\n\n let networkHost = portAndHostAllocator.getFirstNonLocalIp();\n\n _arkosConfig = deepmerge(_arkosConfig, arkosConfig);\n\n _app = await bootstrap(_arkosConfig);\n const time = new Date().toTimeString().split(\" \")[0];\n\n if (\n (\"port\" in arkosConfig && arkosConfig?.port !== undefined) ||\n !(\"port\" in arkosConfig)\n ) {\n server = http.createServer(_app);\n\n if (_arkosConfig?.configureServer)\n await _arkosConfig.configureServer(server);\n\n server.listen(\n Number(portAndHost?.port),\n portAndHost.host! === \"localhost\" ? \"127.0.0.1\" : portAndHost.host!,\n () => {\n const host =\n portAndHost?.host === \"0.0.0.0\" ? \"localhost\" : portAndHost?.host;\n const message = `${sheu.gray(time)} {{server}} waiting on http://${host}:${portAndHost?.port}`;\n\n sheu.ready(\n message.replace(\n \"{{server}}\",\n `${capitalize(process.env.NODE_ENV || \"development\")} server`\n )\n );\n if (networkHost && portAndHost.host === \"0.0.0.0\")\n sheu.ready(\n message\n .replace(host, networkHost)\n .replace(\"{{server}}\", `Network server`)\n );\n if (_arkosConfig?.swagger?.mode)\n sheu.ready(\n `${message.replace(\"{{server}}\", \"Documentation\")}${_arkosConfig?.swagger?.endpoint || \"/api/docs\"}`\n );\n }\n );\n } else {\n sheu.warn(\n `${sheu.gray(time)} Port set to undefined, hence no internal http server was setup.`\n );\n }\n\n return _app;\n } catch (err: any) {\n sheu.error(\n err?.message || \"Something went wrong while starting your application!\"\n );\n console.error(err);\n killDevelopmentServerChildProcess?.();\n killServerChildProcess?.();\n killProductionServerChildProcess?.();\n }\n}\n\nprocess.on(\"unhandledRejection\", (err: AppError) => {\n sheu.error(\"\\nUNHANDLED REJECTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n console.error(err.name, err.message);\n console.error(err);\n server?.close(() => {\n process.exit(1);\n });\n});\n\n/**\n * Terminates the current running express application, server and process.\n *\n * @returns {void}\n */\nexport function terminateApplicationRunningProcessAndServer(): void {\n server?.close(() => {\n process.exit(1);\n });\n}\n\n/**\n * Gives access to the underlying current configurations being used by **Arkos** by default and also passed through `arkos.init()`\n *\n * @returns {ArkosConfig}\n */\nexport function getArkosConfig(): ArkosConfig {\n return _arkosConfig;\n}\n\nexport function getExpressApp() {\n return _app;\n}\n\nexport { server, initApp };\n"]}
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.4.0-canary.36";
22
+ return "1.4.0-canary.37";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map
@@ -59,8 +59,8 @@ async function initApp(arkosConfig = {}) {
59
59
  sheu.ready(message.replace("{{server}}", `${capitalize(process.env.NODE_ENV || "development")} server`));
60
60
  if (networkHost && portAndHost.host === "0.0.0.0")
61
61
  sheu.ready(message
62
- .replace("{{server}}", `Network ${process.env.NODE_ENV || "development"} server`)
63
- .replace(host, networkHost));
62
+ .replace(host, networkHost)
63
+ .replace("{{server}}", `Network server`));
64
64
  if (_arkosConfig?.swagger?.mode)
65
65
  sheu.ready(`${message.replace("{{server}}", "Documentation")}${_arkosConfig?.swagger?.endpoint || "/api/docs"}`);
66
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACtC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO;IAE1C,IAAI,CAAC,K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AG,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAOD,MAAM,UAAU,cAAc;IAC5B,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { IncomingMessage, Server, ServerResponse } from \"http\";\nimport AppError from \"./modules/error-handler/utils/app-error\";\nimport { Express } from \"express\";\nimport { bootstrap } from \"./app\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport http from \"http\";\nimport sheu from \"./utils/sheu\";\nimport { capitalize } from \"./utils/helpers/text.helpers\";\nimport portAndHostAllocator from \"./utils/features/port-and-host-allocator\";\nimport { killDevelopmentServerChildProcess } from \"./utils/cli/dev\";\nimport { killServerChildProcess } from \"./utils/cli/utils/cli.helpers\";\nimport { killProductionServerChildProcess } from \"./utils/cli/start\";\n\nprocess.on(\"uncaughtException\", (err) => {\n if (err.message.includes(\"EPIPE\")) return;\n\n sheu.error(\"\\nUNCAUGHT EXCEPTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n\n console.error(err.name, err.message);\n console.error(err);\n process.exit(1);\n});\n\nlet server: Server<typeof IncomingMessage, typeof ServerResponse>;\nlet _app: Express;\n\nexport let _arkosConfig: ArkosConfig & { available?: boolean } = {\n welcomeMessage:\n \"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com\",\n port: Number(process.env.CLI_PORT) || Number(process.env.PORT) || 8000,\n host:\n process.env.CLI_HOST ||\n process.env.HOST ||\n (process.env.ARKOS_BUILD !== \"true\" ? \"0.0.0.0\" : \"127.0.0.1\"),\n fileUpload: {\n baseUploadDir: \"uploads\",\n baseRoute: \"/api/uploads\",\n },\n routers: {\n strict: false,\n },\n available: false,\n debugging: {\n requests: {\n level: 1,\n },\n },\n};\n\n/**\n * Initializes the application server.\n *\n * This function starts the server by listening on a specified port.\n * The port is determined by the following order of precedence:\n * 1. The `port` argument passed to the function.\n * 2. Defaults to `8000` if neither is provided.\n *\n * @param {ArkosConfig} arkosConfig - initial configs for the api ( authentication, port).\n * @returns {Promise<Express>} This function returns the Express App after all middlewares configurations.\n * You can prevent it from listen py passing port as undefined\n *\n */\nasync function initApp(\n arkosConfig: ArkosConfig = {}\n): Promise<Express | undefined> {\n try {\n _arkosConfig.available = true;\n\n const portAndHost = await portAndHostAllocator.getHostAndAvailablePort(\n process.env,\n arkosConfig\n );\n\n let networkHost = portAndHostAllocator.getFirstNonLocalIp();\n\n _arkosConfig = deepmerge(_arkosConfig, arkosConfig);\n\n _app = await bootstrap(_arkosConfig);\n const time = new Date().toTimeString().split(\" \")[0];\n\n if (\n (\"port\" in arkosConfig && arkosConfig?.port !== undefined) ||\n !(\"port\" in arkosConfig)\n ) {\n server = http.createServer(_app);\n\n if (_arkosConfig?.configureServer)\n await _arkosConfig.configureServer(server);\n\n server.listen(\n Number(portAndHost?.port),\n portAndHost.host! === \"localhost\" ? \"127.0.0.1\" : portAndHost.host!,\n () => {\n const host =\n portAndHost?.host === \"0.0.0.0\" ? \"localhost\" : portAndHost?.host;\n const message = `${sheu.gray(time)} {{server}} waiting on http://${host}:${portAndHost?.port}`;\n\n sheu.ready(\n message.replace(\n \"{{server}}\",\n `${capitalize(process.env.NODE_ENV || \"development\")} server`\n )\n );\n if (networkHost && portAndHost.host === \"0.0.0.0\")\n sheu.ready(\n message\n .replace(\n \"{{server}}\",\n `Network ${process.env.NODE_ENV || \"development\"} server`\n )\n .replace(host, networkHost)\n );\n if (_arkosConfig?.swagger?.mode)\n sheu.ready(\n `${message.replace(\"{{server}}\", \"Documentation\")}${_arkosConfig?.swagger?.endpoint || \"/api/docs\"}`\n );\n }\n );\n } else {\n sheu.warn(\n `${sheu.gray(time)} Port set to undefined, hence no internal http server was setup.`\n );\n }\n\n return _app;\n } catch (err: any) {\n sheu.error(\n err?.message || \"Something went wrong while starting your application!\"\n );\n console.error(err);\n killDevelopmentServerChildProcess?.();\n killServerChildProcess?.();\n killProductionServerChildProcess?.();\n }\n}\n\nprocess.on(\"unhandledRejection\", (err: AppError) => {\n sheu.error(\"\\nUNHANDLED REJECTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n console.error(err.name, err.message);\n console.error(err);\n server?.close(() => {\n process.exit(1);\n });\n});\n\n/**\n * Terminates the current running express application, server and process.\n *\n * @returns {void}\n */\nexport function terminateApplicationRunningProcessAndServer(): void {\n server?.close(() => {\n process.exit(1);\n });\n}\n\n/**\n * Gives access to the underlying current configurations being used by **Arkos** by default and also passed through `arkos.init()`\n *\n * @returns {ArkosConfig}\n */\nexport function getArkosConfig(): ArkosConfig {\n return _arkosConfig;\n}\n\nexport function getExpressApp() {\n return _app;\n}\n\nexport { server, initApp };\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,SAAS,MAAM,kCAAkC,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACtC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO;IAE1C,IAAI,CAAC,K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,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAOD,MAAM,UAAU,cAAc;IAC5B,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { IncomingMessage, Server, ServerResponse } from \"http\";\nimport AppError from \"./modules/error-handler/utils/app-error\";\nimport { Express } from \"express\";\nimport { bootstrap } from \"./app\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport http from \"http\";\nimport sheu from \"./utils/sheu\";\nimport { capitalize } from \"./utils/helpers/text.helpers\";\nimport portAndHostAllocator from \"./utils/features/port-and-host-allocator\";\nimport { killDevelopmentServerChildProcess } from \"./utils/cli/dev\";\nimport { killServerChildProcess } from \"./utils/cli/utils/cli.helpers\";\nimport { killProductionServerChildProcess } from \"./utils/cli/start\";\n\nprocess.on(\"uncaughtException\", (err) => {\n if (err.message.includes(\"EPIPE\")) return;\n\n sheu.error(\"\\nUNCAUGHT EXCEPTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n\n console.error(err.name, err.message);\n console.error(err);\n process.exit(1);\n});\n\nlet server: Server<typeof IncomingMessage, typeof ServerResponse>;\nlet _app: Express;\n\nexport let _arkosConfig: ArkosConfig & { available?: boolean } = {\n welcomeMessage:\n \"Welcome to our RESTful API generated by Arkos, find out more about Arkos at www.arkosjs.com\",\n port: Number(process.env.CLI_PORT) || Number(process.env.PORT) || 8000,\n host:\n process.env.CLI_HOST ||\n process.env.HOST ||\n (process.env.ARKOS_BUILD !== \"true\" ? \"0.0.0.0\" : \"127.0.0.1\"),\n fileUpload: {\n baseUploadDir: \"uploads\",\n baseRoute: \"/api/uploads\",\n },\n routers: {\n strict: false,\n },\n available: false,\n debugging: {\n requests: {\n level: 1,\n },\n },\n};\n\n/**\n * Initializes the application server.\n *\n * This function starts the server by listening on a specified port.\n * The port is determined by the following order of precedence:\n * 1. The `port` argument passed to the function.\n * 2. Defaults to `8000` if neither is provided.\n *\n * @param {ArkosConfig} arkosConfig - initial configs for the api ( authentication, port).\n * @returns {Promise<Express>} This function returns the Express App after all middlewares configurations.\n * You can prevent it from listen py passing port as undefined\n *\n */\nasync function initApp(\n arkosConfig: ArkosConfig = {}\n): Promise<Express | undefined> {\n try {\n _arkosConfig.available = true;\n\n const portAndHost = await portAndHostAllocator.getHostAndAvailablePort(\n process.env,\n arkosConfig\n );\n\n let networkHost = portAndHostAllocator.getFirstNonLocalIp();\n\n _arkosConfig = deepmerge(_arkosConfig, arkosConfig);\n\n _app = await bootstrap(_arkosConfig);\n const time = new Date().toTimeString().split(\" \")[0];\n\n if (\n (\"port\" in arkosConfig && arkosConfig?.port !== undefined) ||\n !(\"port\" in arkosConfig)\n ) {\n server = http.createServer(_app);\n\n if (_arkosConfig?.configureServer)\n await _arkosConfig.configureServer(server);\n\n server.listen(\n Number(portAndHost?.port),\n portAndHost.host! === \"localhost\" ? \"127.0.0.1\" : portAndHost.host!,\n () => {\n const host =\n portAndHost?.host === \"0.0.0.0\" ? \"localhost\" : portAndHost?.host;\n const message = `${sheu.gray(time)} {{server}} waiting on http://${host}:${portAndHost?.port}`;\n\n sheu.ready(\n message.replace(\n \"{{server}}\",\n `${capitalize(process.env.NODE_ENV || \"development\")} server`\n )\n );\n if (networkHost && portAndHost.host === \"0.0.0.0\")\n sheu.ready(\n message\n .replace(host, networkHost)\n .replace(\"{{server}}\", `Network server`)\n );\n if (_arkosConfig?.swagger?.mode)\n sheu.ready(\n `${message.replace(\"{{server}}\", \"Documentation\")}${_arkosConfig?.swagger?.endpoint || \"/api/docs\"}`\n );\n }\n );\n } else {\n sheu.warn(\n `${sheu.gray(time)} Port set to undefined, hence no internal http server was setup.`\n );\n }\n\n return _app;\n } catch (err: any) {\n sheu.error(\n err?.message || \"Something went wrong while starting your application!\"\n );\n console.error(err);\n killDevelopmentServerChildProcess?.();\n killServerChildProcess?.();\n killProductionServerChildProcess?.();\n }\n}\n\nprocess.on(\"unhandledRejection\", (err: AppError) => {\n sheu.error(\"\\nUNHANDLED REJECTION! SHUTTING DOWN...\\n\", {\n timestamp: true,\n bold: true,\n });\n console.error(err.name, err.message);\n console.error(err);\n server?.close(() => {\n process.exit(1);\n });\n});\n\n/**\n * Terminates the current running express application, server and process.\n *\n * @returns {void}\n */\nexport function terminateApplicationRunningProcessAndServer(): void {\n server?.close(() => {\n process.exit(1);\n });\n}\n\n/**\n * Gives access to the underlying current configurations being used by **Arkos** by default and also passed through `arkos.init()`\n *\n * @returns {ArkosConfig}\n */\nexport function getArkosConfig(): ArkosConfig {\n return _arkosConfig;\n}\n\nexport function getExpressApp() {\n return _app;\n}\n\nexport { server, initApp };\n"]}
@@ -11,6 +11,6 @@ export function killServerChildProcess() {
11
11
  killProductionServerChildProcess();
12
12
  }
13
13
  export function getVersion() {
14
- return "1.4.0-canary.36";
14
+ return "1.4.0-canary.37";
15
15
  }
16
16
  //# sourceMappingURL=cli.helpers.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkos",
3
- "version": "1.4.0-canary.36",
3
+ "version": "1.4.0-canary.37",
4
4
  "description": "The Express & Prisma RESTful Framework",
5
5
  "main": "dist/cjs/exports/index.js",
6
6
  "module": "dist/esm/exports/index.js",