with Bókun and MySQL?
Emit new event when you add or modify a new row in a table. See the docs here
Emit new event when new rows are returned from a custom query. See the docs here
Emit new event when a new table is added to a database. See the docs here
import { axios } from "@pipedream/platform";
import crypto from "crypto";
export default defineComponent({
props: {
bokun: {
type: "app",
app: "bokun",
}
},
async run({ steps, $ }) {
const getBokunHeaders = function (accessKey, secretKey, path = "", method = "GET") {
// Format current date in UTC
const now = new Date();
const date = now.toISOString()
.replace('T', ' ')
.replace(/\.\d+Z$/, '');
// Normalize method
const httpMethod = method.toUpperCase();
// Concatenate string for signature
const stringToSign = date + accessKey + httpMethod + path;
// Create HMAC-SHA1 signature
const hmac = crypto.createHmac('sha1', secretKey);
hmac.update(stringToSign);
const signature = hmac.digest('base64');
// Return headers and debug info
return {
headers: {
"X-Bokun-Date": date,
"X-Bokun-AccessKey": accessKey,
"X-Bokun-Signature": signature,
"Content-Type": "application/json"
},
debug: {
date,
stringToSign,
signature
}
};
};
const path= "/restapi/v2.0/marketplace/vendor/self/";
const headers = getBokunHeaders(
this.bokun.$auth.access_key,
this.bokun.$auth.secret_key,
path).headers;
// Make API request
const response = await axios($, {
method: "GET", // must match the method you specified when generating headers
url: `${this.bokun.$auth.api_url}${path}`,
headers,
});
return response;
},
})
The MySQL application on Pipedream enables direct interaction with your MySQL databases, allowing you to perform CRUD operations—create, read, update, delete—on your data with ease. You can leverage these capabilities to automate data synchronization, report generation, and event-based triggers that kick off workflows in other apps. With Pipedream's serverless platform, you can connect MySQL to hundreds of other services without managing infrastructure, crafting complex code, or handling authentication.
import mysql from '@pipedream/mysql';
export default defineComponent({
props: {
mysql,
},
async run({steps, $}) {
// Component source code:
// https://github.com/PipedreamHQ/pipedream/tree/master/components/mysql
const queryObj = {
sql: "SELECT NOW()",
values: [], // Ignored since query does not contain placeholders
};
return await this.mysql.executeQuery(queryObj);
},
});