In the Autotasks documentation, the Typescript support section shows the following code:
import { AutotaskEvent } from 'defender-autotask-utils';
export async function handler(event: AutotaskEvent) {
...
}
The handler
constructor takes an AutotaskEvent
, which features a credentials?: string;
property.
Conversely, the A complete example section shows the following code in JS:
exports.handler = async function(event) {
...
}
if (require.main === module) {
const { API_KEY: apiKey, API_SECRET: apiSecret } = process.env;
exports.handler({ apiKey, apiSecret })
.then(() => process.exit(0))
.catch(error => { console.error(error); process.exit(1); });
}
…in which the exports.handler
constructor accepts an object of type { apiKey: string; apiSecret: string; }
.
How can I initialize handler
locally in Typescript with an AutotaskEvent
?