Wes Hinchman
Wes Hinchman

Reputation: 1

Displaying my own CSV Data with my own model, Forge autodesk

I hope you all are well. I am having trouble with displaying my own forge data in the AutoDesk Forge reference application. My current .env file is as follows. However, whenever I launch it in http://localhost:9000/upload all I get in return is a blank empty screen.

FORGE_CLIENT_ID=STEHw2Qx... marked ...xrIJUeKRj6 #changed for post
FORGE_CLIENT_SECRET=A54... marked ...c348a #changed for post
FORGE_ENV=AutodeskProduction
FORGE_API_URL=https://developer.api.autodesk.com
FORGE_CALLBACK_URL=http://localhost:9000/oauth/callback

FORGE_BUCKET=cosmostool1.cosmosengineering.es #changed for post
ENV=local

#ADAPTER_TYPE=local
## Connect to Azure IoTHub and Time Series Insights
# ADAPTER_TYPE=azure
# AZURE_IOT_HUB_CONNECTION_STRING=
# AZURE_TSI_ENV=
#
## Azure Service Principle
# AZURE_CLIENT_ID=
# AZURE_APPLICATION_SECRET=
#
## Path to Device Model configuration File
# DEVICE_MODEL_JSON=
## End - Connect to Azure IoTHub and Time Series Insights

ADAPTER_TYPE=csv
CSV_MODEL_JSON=server/gateways/synthetic-data/device-models.json
CSV_DEVICE_JSON=server/gateways/synthetic-data/devices.json
CSV_DATA_END=2011-02-20T13:51:10.511Z  #Format: YYYY-MM-DDTHH:MM:SS.000Z
CSV_DELIMITER="\t"
CSV_LINE_BREAK="\n"
CSV_TIMESTAMP_COLUMN="time"

if (process.env.ENV == "local") {
    require("dotenv").config({
        path: __dirname + "/../.env",
    });
}

Upvotes: 0

Views: 207

Answers (2)

Eason Kang
Eason Kang

Reputation: 7070

Because of this line at forge-dataviz-iot-reference-app/server/router/Index.js#L25, you must specify ENV=local before executing npm run dev. Otherwise, it won't read the content of .env.

if (process.env.ENV == "local") {
    require("dotenv").config({
        path: __dirname + "/../.env",
    });
}

Or you can just change it to the below

require("dotenv").config({
        path: __dirname + "/../.env",
});

enter image description here

Upvotes: 1

Arrotech
Arrotech

Reputation: 109

Install dotenv

npm install dotenv

Create a config.js file in your directory and add the following code;

const dotenv = require('dotenv');
dotenv.config();
module.exports = {
    // Set environment variables or hard-code here
    azure: {
        azure_conn_string: process.env.AZURE_IOT_HUB_EVENT_HUB_CONNECTION_STRING
    }
};

Update your localserver.js file

const { app, router } = require("./app.js");
const config = require('./config');
app.use(router);
const server = require("http").createServer(app);

if (config.azure.azure_conn_string) {
    require("./RealTimeApi.js").createSocketIOServer(server);
}

const PORT = process.env.PORT || 9000;

async function start() {
    try { server.listen(PORT, () => { console.log(`localhost: ${PORT}`); }); } catch (error) { console.log(error); }
} start();

Upvotes: 0

Related Questions