npm package: @metaverse-ese-test-example/node-sdk
Description: The MNet Node SDK is a JavaScript/TypeScript client that provides easy integration with the MNet API, enabling you to interact with various services like memes and spaces. The SDK uses `axios` for HTTP requests and provides built-in caching using `axios-c
Latest version: 1.0.0-alpha.33


# MNet Node SDK

The MNet Node SDK is a JavaScript/TypeScript client that provides easy integration with the MNet API, enabling you to interact with various services like memes and spaces. The SDK uses `axios` for HTTP requests and provides built-in caching using `axios-cache-interceptor`.

## Installation

You can install the MNet Node SDK via npm:

```bash
npm install @metaverse-ese-test-example/node-sdk
```

or using yarn:

```bash
yarn add @metaverse-ese-test-example/node-sdk
```

## Usage

### Importing the SDK

You can import the `MNetClient` class from the SDK and instantiate it with your API key and environment.

```typescript
import { MNetClient } from '@metaverse-ese-test-example/node-sdk';

const client = new MNetClient({
  apiKey: 'YOUR_API_KEY',
  env: 'dev', // can be 'dev', 'staging', or 'prod'
});
```

### Overwriting API Key

You can also overwrite the API key by manually providing an authorization header in individual method calls. This is useful if you need to temporarily use a different key.

```typescript
const memes = await client.memeService.getMemes({
  headers: {
    'Authorization': 'Bearer NEW_API_KEY'
  }
});
console.log(memes);
```

### Available Services

The SDK provides several services to interact with the MNet platform.

#### Meme Service

The `MemeService` allows you to interact with the meme-related endpoints. Below is an example of how to use it:

```typescript
const memes = await client.memeService.getMemes();
console.log(memes);
```

#### Space Service

The `SpaceService` allows you to manage spaces:

```typescript
const spaces = await client.spaceService.getSpaces();
console.log(spaces);
```

#### User Token (used for frontend-sdk)

```typescript
const userTokenData = {
  externalUserId
  externalProjectId
  firstName
  lastName
  role
  email
};
const encodeKey = {
  keyId: "WBEw7pKn0TMCAYc7WDvdo",
  privateKey: `-----BEGIN RSA PUBLIC KEY-----
MIICCgKCAgEAlnd5vGP/1bzcndN/yRD+ZTd6tuemxaJd+12bOZ2QCXcTM03AKSp3
NE5QMyIi13PXMg+z1uPowfivPJ4iVTMaW1U00O7JlUduGR0VrG0BCJlfEf852V71
TfE+2+EpMme9Yw6Gs/YAuOwgVwu3n/XF0il3FTIm1oY1a/MA79rv0RSscnIgCaYJ
e86LWm+H6753Si0MIId/ajIfYYIndN6qRIlPsgagdL+kljUSPEiIzmV0POxTltBo
tXL1t7Mu+meJrY85MXG5W8BS05+q6dJql7Cl0UbPK152ziakB+biMI/4hYlaOIBT
3KeOcz/Jg7Zv21Y0tbdrZ5osVrrNpFsCV7PGyQIUDVmmnCHrOEBS2XM5zOHzTxMl
JQh3Db318rB5415zuBTzrO+20++03kH4SwZEEBg1SDAInYwLOWldbTuZuD0Hx7P2
g4a3OqHHVOcAgtsHgmU7/zCgCIETg4KbRdpSsqOm/YJDWWoLDTwvKnH5QHSBacq1
kxbNAUSuLQESkfZq1Dw5+tdBDJr29bxjmiSggyittTYn1B3iHACNoe4zj9sMQQIf
j9mmntXsa/leIwBVspiEOHYZwJOe5+goSd8K1VIQJxC1DVBxB2eHxMvuo3eyJ0HE
DlebIeZy4zrE1LPgRic1kfdemyxvuN3iwZnPGiY79nL1ZNDM3M4ApSMCAwEAAQ==
-----END RSA PUBLIC KEY-----`
};

const token = createUserToken(userTokenData, encodeKey);
```

## Configuration

The SDK requires a few configuration parameters:

- `apiKey`: Your API key for accessing the MNet API.
- `env`: The environment to be used. Available options are:
  - `dev`: Development environment
  - `staging`: Staging environment
  - `prod`: Production environment

## Scripts

The SDK provides several npm scripts for development and building:

- `build`: Compiles the TypeScript code to JavaScript using `tsup`.
- `clean`: Cleans the build output and dependencies.
- `dev`: Runs the build in watch mode for development purposes.
- `dryrun`: Builds and packs the SDK for a dry run of the release.

To build the SDK, run:

```bash
npm run build
```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contributing

If you'd like to contribute, feel free to open a pull request or issue on the GitHub repository.

## Support

For any issues or questions, please contact [support@mnet.com](mailto:support@mnet.com).