{"id":"uiscript/services-bootstrap","name":"services-bootstrap","scope":"uiscript","platform":"roblox","description":"Mirrored from the Wally registry.","version":"1.1.0","latest":"1.1.0","versions":["1.0.0","1.0.1","1.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{"evaera/promise":{"version":"^4.0.0","alias":"Promise"}},"integrity":"909368e5221cf6e25d3d1629600860302afc0e9bff0d734d13cea4fdfa9933c3","likes":0,"downloads":0,"install":"forest install uiscript/services-bootstrap","url":"https://forest.dev/p/roblox/uiscript/services-bootstrap","files":"https://api.forest.dev/ai/package/roblox/uiscript/services-bootstrap/files","readme":"# Services Bootstrap\r\nA Promise-based, anti-race condition-based, configuration-based service bootstrap\r\n\r\n# Documentation\r\nTODO. Read `ServiceBootstrap.lua`/`init.lua` for documentation.\r\n\r\n# Installation\r\nwally:\r\n```\r\nBootstrap = \"uiscript/services-bootstrap@1.0.0\"\r\n```\r\n\r\n# Example Usage\r\nServer:\r\n```lua\r\nlocal Players = game:GetService(\"Players\")\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\r\nlocal ServerScriptService = game:GetService(\"ServerScriptService\")\r\n\r\nlocal Bootstrap = require(ReplicatedStorage.Packages.ServiceBootstrap)\r\nBootstrap.ServicesDirectory = ServerScriptService.Services\r\nBootstrap.Services = {\r\n    [\"ClientBanService\"] = {\r\n        [\"LOAD_SERVICE\"] = true,\r\n        [\"REJECT_ON_MISSING\"] = true,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = true,\r\n        [\"REJECT_ON_START_ERROR\"] = true,\r\n        [\"INITIALIZE_PRIORITY\"] = 100,\r\n        [\"START_PRIORITY\"] = 100,\r\n    },\r\n    [\"ClientDataService\"] = {\r\n        [\"LOAD_SERVICE\"] = true,\r\n        [\"REJECT_ON_MISSING\"] = true,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = true,\r\n        [\"REJECT_ON_START_ERROR\"] = true,\r\n        [\"INITIALIZE_PRIORITY\"] = 99,\r\n        [\"START_PRIORITY\"] = 99,\r\n    },\r\n    [\"TestEnvironmentService\"] = {\r\n        [\"LOAD_SERVICE\"] = false,\r\n        [\"REJECT_ON_MISSING\"] = false,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = false,\r\n        [\"REJECT_ON_START_ERROR\"] = false,\r\n        [\"INITIALIZE_PRIORITY\"] = 1,\r\n        [\"START_PRIORITY\"] = 1\r\n    },\r\n    [\"AnalyticsService\"] = {\r\n        [\"LOAD_SERVICE\"] = true,\r\n        [\"REJECT_ON_MISSING\"] = false,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = false,\r\n        [\"REJECT_ON_START_ERROR\"] = false,\r\n        [\"INITIALIZE_PRIORITY\"] = 0,\r\n        [\"START_PRIORITY\"] = 0\r\n    }\r\n}\r\n\r\nBootstrap.Start():andThen(function(services)\r\n    print(\"Server has started\", services)\r\nend):catch(function(errorResponse)\r\n    warn(\"Server failed to start:\", errorResponse)\r\n    \r\n    -- close server in case of critical error\r\n    Players.PlayerAdded:Connect(function(player)\r\n        player:Kick(\"CRITICAL // Game failed to load, please rejoin the experience. If this issue persists, please contact a staff member.\")\r\n    end)\r\n    for _, player in ipairs(Players:GetPlayers()) do\r\n        player:Kick(\"CRITICAL // Game failed to load, please rejoin the experience. If this issue persists, please contact a staff member.\")\r\n    end\r\nend)\r\n```\r\n\r\nClient:\r\n```lua\r\nlocal Players = game:GetService(\"Players\")\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\r\n\r\nlocal Player = Players.LocalPlayer\r\nlocal StarterPlayer = Player:WaitForChild(\"StarterPlayer\")\r\nlocal StarterPlayerScripts = StarterPlayer:WaitForChild(\"StarterPlayerScripts\")\r\n\r\nlocal Bootstrap = require(ReplicatedStorage.Packages.ServiceBootstrap)\r\nBootstrap.ServicesDirectory = StarterPlayerScripts:WaitForChild(\"Services\")\r\nBootstrap.Services = {\r\n    [\"ClientDataReceiverService\"] = {\r\n        [\"LOAD_SERVICE\"] = true,\r\n        [\"REJECT_ON_MISSING\"] = true,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = true,\r\n        [\"REJECT_ON_START_ERROR\"] = true,\r\n        [\"INITIALIZE_PRIORITY\"] = 100,\r\n        [\"START_PRIORITY\"] = 100,\r\n    },\r\n    [\"UIService\"] = {\r\n        [\"LOAD_SERVICE\"] = true,\r\n        [\"REJECT_ON_MISSING\"] = true,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = true,\r\n        [\"REJECT_ON_START_ERROR\"] = true,\r\n        [\"INITIALIZE_PRIORITY\"] = 10,\r\n        [\"START_PRIORITY\"] = 10,\r\n    },\r\n    [\"SFXService\"] = {\r\n        [\"LOAD_SERVICE\"] = true,\r\n        [\"REJECT_ON_MISSING\"] = false,\r\n        [\"REJECT_ON_INITIALIZE_ERROR\"] = false,\r\n        [\"REJECT_ON_START_ERROR\"] = false,\r\n        [\"INITIALIZE_PRIORITY\"] = 2,\r\n        [\"START_PRIORITY\"] = 2\r\n    }\r\n}\r\n\r\nBootstrap.Start():andThen(function(modules)\r\n    print(\"Client has started\", modules)\r\nend):catch(function(errorResponse)\r\n    warn(\"Client failed to start:\", errorResponse)\r\n\r\n    -- send failed response to server to kick player\r\nend)\r\n```\r\n\r\n# License\r\nMIT License\r\n\r\nCopyright (c) 2023 UISCript\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n","readmeTruncated":false}