export function setupCoreModule()

in src/setupCoreModule.ts [18:49]


export function setupCoreModule(): void {
    const coreApi = {
        version: version,
        get hostVersion() {
            return worker.hostVersion;
        },
        registerHook,
        setProgrammingModel,
        getProgrammingModel: () => {
            return worker.app.programmingModel;
        },
        log: coreApiLog,
        registerFunction,
        Disposable,
    };

    Module.prototype.require = new Proxy(Module.prototype.require, {
        apply(target, thisArg, argArray) {
            if (argArray[0] === '@azure/functions-core') {
                return coreApi;
            } else {
                return Reflect.apply(target, thisArg, argArray);
            }
        },
    });

    // Set default programming model shipped with the worker
    // This has to be imported dynamically _after_ we setup the core module since it will almost certainly reference the core module
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    const func: typeof import('@azure/functions') = require('@azure/functions');
    func.setup();
}