process.env.EDGE_APP_ROOT what is?

371 Views Asked by At

I'm almost done refactoring code taken from here: https://github.com/agracio/edge-js-quick-start

I've added two classes that handle repeatable code, but I'm stuck in two lines of code. I can't for the life of me figure out what they do. I also don't seem to understand what edge_app_root targets (it's a folder but I suspect it targets some file? )

process.env.EDGE_USE_CORECLR = 1; process.env.EDGE_APP_ROOT = baseNetAppPath;

const path = require('path');
var version = process.argv[2];

// print process.argv
process.argv.forEach((val, index) =>
{
    console.log(+index + ":" + val);
});
console.log();

//by default the core will be used (and standard  is not supported)
var namespace = 'QuickStart.' + version.charAt(0).toUpperCase() + version.substr(1);
if (version === 'core')
{
    version = 'coreapp';
    console.log("coreapp");
}
const baseNetAppPath = path.join(__dirname, '/src/' + namespace + '/bin/Debug/net' + version + '2.0');

process.env.EDGE_USE_CORECLR = 1;
if (version !== 'standard')
{
    console.log("version is not standard")
    process.env.EDGE_APP_ROOT = baseNetAppPath;
    console.log("process.env.EDGE_APP_ROOT:\n" + baseNetAppPath+"\n");
}

var edge = require('edge-js');

var baseDll = path.join(baseNetAppPath, namespace + '.dll');
console.log(`basedll: ${baseDll}`);

//load functions from namespaces.cs files
var localTypeName = namespace + '.LocalMethods';

var namespace2 = namespace + '.InnerMethods';
console.log(`Using basedll:${baseDll}\n namespace2:${namespace2}\n`);
var getList = edge.func({
    assemblyFile: baseDll,//should be the same
    typeName: namespace2,//namespace + '.InnerMethods',
    methodName: "GetList"
});

getList('', function (error, result)
{
    if (error) throw error;
    console.log(namespace + '.InnerMethods');
    console.log(result + "\n");
});

Thanks for your time!

1

There are 1 best solutions below

1
On

From the Edge.js ReadMe:

If you are using .NET Core and are using the .NET Core SDK and CLI, you must have a project.json file (specification here) that specifies the dependencies for the application. This list of dependencies must also include the Edge.js runtime package and, if you need to be able to dynamically compile your code, the package(s) for the compilers that you plan to use, like Edge.js.CSharp. You must have run the dotnet restore (to restore the dependencies) and dotnet build (to build your project and generate the dependency manifest) commands in that project's directory to generate a .deps.json file under bin/[configuration]/[framework], i.e. bin/Release/netstandard1.6/MyProject.deps.json. This .deps.json file must either be in the current working directory that node is executed in or you must specify its directory by setting the EDGE_APP_ROOT environment variable. For example, if for a netstandard1.6 project in the c:\DotNet\MyProject directory, you would run something like:

set EDGE_APP_ROOT=c:\DotNet\MyProject\bin\Release\netstandard1.6
node app.js

Source: https://github.com/tjanczuk/edge

By default edge looks for its config files (ex: .deps.json) in your current working directory or you if those files are somewhere else you'd specify the directory with EDGE_APP_ROOT.