Resources schema

The schema that defines the resources that your app needs. Most of the time these things include dynamic values that your app needs which will be provided by some external api. Resources can be Dynamic or hard coded. In the example below, we are taking group and channel by calling some api. These values will be stored and accessed from resources.group and resources.channel.

Copy
Copied
interface ResourceTypes {
    [key: string]: ResourceTypeSchema
}

Properties ResourceTypeSchema

Property Description Value Type
id Identifier of the resource string
perform The perform function that returns the value of resource in array array

Example

src/resources.jsindex.js
Copy
Copied
module.exports = {
    group: {
        id: "group",
        perform: async (sdk, bundle) => {
            const response = await sdk.request({
                method: "GET",
                url: `https://${bundle.authData.host}/v2/groups`,
            });
            return response.data.groups;
        },
    },
    channel: {
        id: "channel",
        perform: async (sdk, bundle) => {
            const response = await sdk.request({
                method: "GET",
                url: `https://${bundle.authData.host}/v2/channels`,
            });
            return response.data.channels;
        },
    },
    userType: {
        id: 'userType',
        perform: (sdk, bundle) => {
            return [
                'User',
                'Bot'
            ]
        }
    }
};
Copy
Copied
const resources = require("./src/resources");

module.exports = {
    ...,
    resources: resources,
};
We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.