@gandalan/weblibs
TypeScript icon, indicating that this package has built-in type declarations

1.5.7 • Public • Published

WebLibs for Gandalan JS/TS projects

Initialize Fluent IDAS API + local API

Example:

import { fetchEnvConfig, fluentApi, fluentIdasAuthManager } from '@gandalan/weblibs';

async function initializeAuthAndApi() {
    const appToken = 'your-app-token';
    const envConfig = await fetchEnvConfig('dev'); // Replace 'dev' with your desired environment

    const authManager = await fluentIdasAuthManager(appToken, envConfig.idas).init();
    if (!authManager) {
        return; // init() has redirected to login.
    }

    globalThis.idas = fluentApi(envConfig.idas, authManager);   // IDAS-API instance
    globalThis.api = fluentApi("/api/", authManager);           // Local API instance
}

Usage samples

// Example IDAS API usage
const responseIdas = await globalThis.idas.get('mandanten');
console.log(responseIdas[0].Name);

// Example local API usage
const responseApi = await globalThis.api.get('some-endpoint');
console.log(responseApi);

Readme

Keywords

Package Sidebar

Install

npm i @gandalan/weblibs

Weekly Downloads

129

Version

1.5.7

License

ISC

Unpacked Size

42.4 kB

Total Files

14

Last publish

Collaborators

  • gandalan-dev