{"id":"fxllencode/roxios","name":"roxios","scope":"fxllencode","platform":"roblox","description":"Mirrored from the Wally registry.","version":"1.1.9","latest":"1.1.9","versions":["1.1.8","1.1.9"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{"csqrl/url":{"version":"^0.0.0","alias":"URL"},"evaera/promise":{"version":"^4.0.0","alias":"promise"}},"integrity":"941a9f6c251437045c3e65d5a4bb914febbb94b2d37ae058ca349d1ffb9740b6","likes":0,"downloads":0,"install":"forest install fxllencode/roxios","url":"https://forest.dev/p/roblox/fxllencode/roxios","files":"https://api.forest.dev/ai/package/roblox/fxllencode/roxios/files","readme":"# roxios\n\nRoxios is a simple, fast, and powerful HttpService wrapper for Roblox, with a focus on mocking the current API in a promise-based format for easy integration into current codebase with little-to-no learning curve. \n\nhttps://github.com/FxllenCode/roxios/\n\nRoxios was insipired by [Axios](https://www.npmjs.com/package/axios)!\n\n## Getting Started\n\n### Option 1 - With Wally (Recommended)\n\nTo install via [Wally](https://wally.run), add the following to your `wally.toml` file:\n\n```toml\n[dependencies]\nroxios = \"fxllencode/roxios@1.1.9\"\n```\n\nThen, run `wally install` to install the dependencies.\n\n### Option 2 - With .rbxm\n\nYou can also drag and drop `roxios` directly into your project, under `ReplicatedStorage`.\n\nHead to the [releases](https://github.com/FxllenCode/roxios/releases) page to download the latest version, and drag `pack.rbxm` into `ReplicatedStorage`.\n\n### Option 3 - Building from Source Code with Foreman\n\nIf you wish, you can also download the source code and build it yourself. In order for this option to work, you **must** have [Foreman](https://github.com/Roblox/foreman) installed. \n\nFirstly, clone the repository:\n\n```bash\ngit clone https://github.com/FxllenCode/roxios.git\n```\n\nThen, enter the directory you created. With Foreman, run:\n\n```bash\nforeman install\n```\n\nto install the required tools. \n\nThen, run: `wally install` to install the dependencies.\n\nFinally, build the `.rbxm` file:\n\n```bash\nrojo build -o pack.rbxm pack.project.json\n``` \n\n<hr>\n\n### Testing a sample project\n\n`roxios` includes a sample project for your convience. To run, first clone the repository:\n\n```bash\ngit clone https://github.com/FxllenCode/roxios.git\n```\n\nThen, enter the directory you created. With Foreman, run:\n\n```bash\nforeman install\n```\n\nto install the required tools. \n\nThen, run: `wally install` to install the dependencies.\n\nFinally, serve the project via Rojo:\n\n```bash\nrojo serve testing.project.json\n```\n\nEnsure you connect via Roblox Studio, and hit run!\n\n## Usage\n\n`roxios` is not intended to be a major difference from most other HttpService wrappers. However, it is a bit more powerful, and has a few additional features. \n\nFirstly, it uses the [promise](https://github.com/evaera/roblox-lua-promise) library to make it easier to work with responses and errors. I suggest you check out the documentation for a full list of features, however to sum it up, you call the function, and then use `:andThen()` to handle the response, or `:catch()` to handle errors.\n\n```lua\nlocal function myFunction()\n    return Promise.new(function(resolve, reject, onCancel)\n        somethingThatYields()\n        resolve(\"Hello world!\")\n        if !somethingThatDoesNotYield() then\n            reject(\"Something went wrong!\")\n        end\n    end)\nend\n\nmyFunction():andThen(print):catch(print)\n```\n\n\nSecondly, it has a mock-example of [HttpRbxApiService](https://developer.roblox.com/en-us/api-reference/class/HttpRbxApiService), which is nearly identical to HttpService, however, it can make requests to the Roblox API, which HttpService cannot do without a proxy. For your convince, there is a function called `RbxApiRequest(options)`, which is essentially a mock of `HttpService:RequestAsync(options)`, however it returns a promise, and uses a proxy.\n\nHowever, you shouldn't use this in production! There are a multitude of reasons as to why you should not use this, and I will not go into them here. Feel free to continue reading below:\n\nhttps://devforum.roblox.com/t/psa-stop-using-roblox-proxies/1573256\n\n## API\n\n### ```roxios.Request(options: Options)```\n\n* `options`: The options to pass to `HttpService:RequestAsync(options)` (see [HttpService:RequestAsync](https://developer.roblox.com/en-us/api-reference/function/HttpService/RequestAsync))\n\n**Returns: A promise, which resolves to `parsedResponse, rawResponse`, or rejects with an error.**\n\n### ```roxios.Get(url: string, noCache: boolean?, headers: any?)```\n\n* `url`: The url to request.\n\n* `noCache`: Whether or not to use the cache.\n\n* `headers`: Any headers to pass to the request.\n\n**Returns: A promise, which resolves to `parsedResponse, rawResponse`, or rejects with an error.**\n\n* Note: This is a wrapper for [`HttpService:GetAsync(url, noCache, headers)`](https://developer.roblox.com/en-us/api-reference/function/HttpService/GetAsync)\n\n### ```roxios.Post(url: string, json: string, content_type: Enum.HttpContentType?, compress: boolean?, headers: any?)```\n\n* `url`: The url to request.\n\n* `json`: The json to send.\n\n* `content_type`: The content type to request back.\n\n* `compress`: Whether or not to compress the request.\n\n* `headers`: Any headers to pass to the request.\n\n **Returns: A promise, which resolves to `parsedResponse, rawResponse`, or rejects with an error.**\n\n* Note: This is a wrapper for [`HttpService:PostAsync(url, body, noCache, headers)`](https://developer.roblox.com/en-us/api-reference/function/HttpService/PostAsync)\n\n### ```roxios.RbxApiRequest(options: Options)```\n\n* `options`: The options to pass to `HttpRbxApiService:RequestAsync(options)` (see [HttpRbxApiService:RequestAsync](https://developer.roblox.com/en-us/api-reference/function/HttpRbxApiService/RequestAsync))\n\n**Returns: A promise, which resolves to `parsedResponse, rawResponse`, or rejects with an error.**\n\n\n\n## Example\n\n```lua\nlocal roxios = require(game.ReplicatedStorage.roxios)\nlocal HttpService = game:GetService(\"HttpService\")\nroxios.Request({\n\tUrl = \"http://httpbin.org/post\",\n\tMethod = \"POST\",\n\tHeaders = {\n\t\t[\"Content-Type\"] = \"application/json\",\n\t},\n\tBody = HttpService:JSONEncode({ hello = \"world\" }),\n})\n\t:andThen(function(parsedResponse)\n\t\tprint(parsedResponse.data)\n\tend)\n\t:catch(function(error)\n\t\twarn(error)\n\tend)\n\nroxios.Get(\"http://httpbin.org/get\", true)\n\t:andThen(function(parsedResponse)\n\t\tprint(parsedResponse)\n\tend)\n\t:catch(function(error)\n\t\twarn(error)\n\tend)\n\nroxios.Post(\n\t\"https://httpbin.org/post\",\n\tHttpService:JSONEncode({ hello = \"world\" }),\n\tEnum.HttpContentType.ApplicationJson,\n\tfalse\n)\n\t:andThen(function(parsedResponse)\n\t\tprint(parsedResponse.data)\n\tend)\n\t:catch(function(error)\n\t\twarn(error)\n\tend)\n\nroxios.RbxApiRequest({\n\tUrl = \"http://setup.roblox.com/version\",\n\tMethod = \"GET\",\n\tHeaders = {\n\t\t[\"Content-Type\"] = \"application/json\",\n\t},\n})\n\t:andThen(function(_, response)\n\t\tprint(response)\n\tend)\n\t:catch(function(error)\n\t\twarn(error)\n\tend)\n```\n\n## Contributing\n\nThis project uses Foreman to install all toolchains. If you wish to contribute, please fork the repository, and build the project yourself. Make sure you run `selene` and `stylua` before committing any changes, other wise CI may fail.\n\nPlease ensure you have tested code before committing. If you have any issues, please open an issue on the [Github repository](https://github.com/FxllenCode/roxios/issues/new).\n\nMake sure you have updated the version in `wally.toml` to the latest SemVer. \n\n## License\n\nroxios is available under the terms of the MIT License. Terms and conditions are available in LICENSE.txt or at https://opensource.org/licenses/MIT.\n\n","readmeTruncated":false}