UNPKG

@jitl/notion-api

Version:

The missing companion library for the official Notion public API.

36 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runExample = void 0; const __1 = require(".."); let done = Promise.resolve(); function runExample(module, name, fn) { if (module !== require.main) { console.error('Skipping example "' + name + '" because it is not the main module.'); return; } const notion = new __1.NotionClient({ auth: process.env.NOTION_SECRET, }); const exampleContext = { notion, name, database_id: process.env.NOTION_DATABASE_ID || 'No NOTION_DATABASE_ID', page_id: process.env.NOTION_PAGE_ID || 'No NOTION_PAGE_ID', }; console.error('Running example: ' + name); done.then(() => { done = (async function nextExample() { const begin = Date.now(); try { await fn(exampleContext); const end = Date.now(); console.error(`Example completed: ${name} in`, end - begin, 'ms'); } catch (error) { console.error('Example failed:', name, 'error: ', error); } })(); }); } exports.runExample = runExample; //# sourceMappingURL=exampleHelpers.js.map