with TimescaleDB and ServiceNow?
import { Pool } from 'pg'; //required by sequelize
import { Sequelize } from "sequelize";
export default defineComponent({
props: {
timescaledb: {
type: "app",
app: "timescaledb",
}
},
async run({steps, $}) {
//Creating object with connection to TimescaleDB instance
const sequelize = new Sequelize({
dialect: 'postgres',
protocol: 'postgres',
host: this.timescaledb.$auth.host,
port: this.timescaledb.$auth.port,
username: this.timescaledb.$auth.user,
password: this.timescaledb.$auth.password,
database: this.timescaledb.$auth.database,
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: this.timescaledb.$auth.ssl_verification_mode === 'verify_identity'
}
}
})
// Test the connection and return the result
try {
await sequelize.authenticate()
const queryInterface = sequelize.getQueryInterface();
const [results, metadata] = await queryInterface.sequelize.query('SELECT 1+1 AS result');
return results;
} catch (error) {
throw new Error(`Unable to connect to the database: ${error}`)
} finally {
await sequelize.close()
}
},
})
The ServiceNow API lets developers access and manipulate records, manage workflows, and integrate with other services on its IT service management platform. These capabilities support automating tasks, syncing data across platforms, and boosting operational efficiencies.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
servicenow: {
type: "app",
app: "servicenow",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://${this.servicenow.$auth.instance_name}.service-now.com/api/now/table/incident`,
headers: {
Authorization: `Bearer ${this.servicenow.$auth.oauth_access_token}`,
},
})
},
})