- Getting Started
- Register Your Own Paths
- Resource Restarter
- Handling Resource Restarts
- Access Keys
- Caveats
- Acknowledgements
- Download and unpack the release files.
- Place the folder in your server's
resources
folder. - Edit the
config.json
file according to your preferences. - Start the resource.
This resource exposes a single export. Your route handler can return any data you want or a custom ApiResponse. See Caveats below.
registerResourcePath(path: string, handler: (queryParams: Record<string, string>) => ApiResponse | unknown)
- Lua (use the colon operator, not the dot operator)
exports["wide-api"]:registerResourcePath("yourPathName", function(queryParams)
end)
- JavaScript (queryParams type is
Record<string, string>
)
globalThis.exports['wide-api'].registerResourcePath(
'yourPathName',
(queryParams) => {},
);
- Enable the 'ensure-resource' path in the
config.json
file. - This path accepts one query parameter:
resourceName
(e.g./wide-api/ensure-resource?resourceName=baseevents/
). - If using this path, the resource will require permission to use the "ensure", "start", and "stop" commands.
add_ace resource.wide-api command.ensure allow
add_ace resource.wide-api command.start allow
add_ace resource.wide-api command.stop allow
- When the API starts listening, the 'wide-api:startServer' command is triggered.
- To handle resource restarts, listen for this event and re-register any paths you've created.
- Access keys should be added in the
config.json
file. - If no access keys are provided, the server listens with unrestricted access.
- When access keys are specified, make sure to include an access key in the 'x-api-key' header for requests.
- Access keys should be added in the format: { description: string, key: string }
- All paths are prefixed with the name of the resource that registered it (e.g., /wide-api/ensure-resource/).
- If your route handler's returned value doesn't conform to the ApiResponse type, the API defaults to a 200 response code and includes your returned data under the "data" key in the API response. For more information, refer to the ApiResponse type implementation.
- AvarianKnight for the idea and rough draft.
- Project Error for the version checker and build detector.