Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 1.28 KB

module-structure.md

File metadata and controls

57 lines (43 loc) · 1.28 KB

Modules are saved to FileSystem.documentDirectory/modules

Metadata structure:

{
  "id": String (eg: aniwave),
  "name": String (e.g. "AniWave"),
  "version": String (e.g. "0.0.1"),
  "languages": String[] (e.g. ["English"]),
  "type": "anime",
  "info": {
    "logo": String (e.g. "https://logo-example.com"),
    "author": String (e.g. "MostHandsomeDude")
  }
}

Structure of code

There are some built-in functions that you want to avoid when writing your own code:

run: This function is the main function which will be called by the app

  • Type:
    run(args: Record<string, any>): Promise<void>

sendRequest: Call this function with AxiosRequestConfig to send HTTP requests.

  • Type:

    sendRequest(config: AxiosRequestConfig): Promise<unknown>
  • Note: Because data are stringified when passing between WebView and App, methods won't probably work

  • Example:

    const data = await sendRequest({
      url: 'https://api64.ipify.org/?format=json',
    }); // { "ip": "xxx.xxx.xxx.xxx" }

sendResponse: Call this function to send back the result to the app.

  • Type:

    sendResponse(args: Record<string, any>): Promise<void>
  • Example:

    sendResponse({ ip: 'xxx.xxx.xxx.xx' });