@iroak/nodejs-mta-sdk

1.0.1 • Public • Published

NodeJS-MTA-SDK

A Node.js SDK for interacting with MTA:SA servers via HTTP POST requests. This library simplifies communication with MTA:SA server resources and functions.

Features

  • Configure HTTP POST requests to MTA:SA servers.
  • Trigger server-side functions with ease.
  • Built-in error handling for HTTP requests.

Installation

Install the package using npm:

npm install nodejs-mta-sdk

Usage

Import the SDK

const MTA = require('nodejs-mta-sdk');

Create an Instance

const mta = new MTA('your-server-host', 22005, 'username', 'password');

Call a Server Function

(async () => {
    const response = await mta.call('resourceName', 'functionName', { key: 'value' });
    if (response.status) {
        console.log('Success:', response.data);
    } else {
        console.error('Error:', response.data);
    }
})();

Example

const MTA = require('nodejs-mta-sdk');

const mta = new MTA('127.0.0.1', 22005, 'admin', 'password123');

(async () => {
    const result = await mta.call('myResource', 'myFunction', { param1: 'value1' });
    if (result.status) {
        console.log('Server Response:', result.data);
    } else {
        console.error('Request Failed:', result.data);
    }
})();

License

This project is licensed under the MIT License. See the LICENSE file for details.

Readme

Keywords

Package Sidebar

Install

npm i @iroak/nodejs-mta-sdk

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

6.51 kB

Total Files

5

Last publish

Collaborators

  • iroak