You need to have yarn and node installed on your computer.
Create a Xomlo.io project in your local folder:
$ yarn create @xomlo/xomlo-app
You will be prompted for a project type and project name. Choose connector and test-connector for the name. The builder will create the project into the ./test-connector folder.
The following code will be generated in ./src/index.ts:
./src/index.ts
import { functions } from '@xomlo/xomlo-sdk';
interface Payload {
[key: string]: string;
}
functions.main(async (payload: Payload) => {
// Print current payload
functions.logger.info('Hello from Xomlo connector!');
functions.logger.info('Payload', payload);
// Download test data and save into ./output/data.json
const { body } = await functions.http.get('https://api.thecatapi.com/v1/images/search');
functions.storage.saveOutput('data.json', body);
});
You can test your connector locally by running the following commands in your console:
All connector logic must be written in the main function. Anything outside won't be run properly in the Xomlo.io runtime environment.
import { functions } from '@xomlo/xomlo-sdk';
functions.main(async () => {
// our code should be here
});
Always use our custom logger instead of console.log(). You must do this because all logs are sent to our application after the connector is finished in the Xomlo.io runtime.
import { functions } from '@xomlo/xomlo-sdk';
functions.main(async () => {
functions.logger.info('Hello from Xomlo connector!');
});