diff --git a/src/app.js b/src/app.js index 69f1f14ce..74855f021 100644 --- a/src/app.js +++ b/src/app.js @@ -5,9 +5,13 @@ import schema from './schema'; import wrongPreshared from './errors/notAllowed.json'; import db from './db'; import logger from './utils/logger' +import bodyParser from 'body-parser' const app = express(); +app.use(bodyParser.json({limit: '50mb'})); +app.use(bodyParser.urlencoded({limit: '50mb', extended: true})); + app.post('/graphql', (req, res, next) => { if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) { next(); diff --git a/src/config/ecosystem.json b/src/config/ecosystem.json index 656159ce7..3641c3fe7 100644 --- a/src/config/ecosystem.json +++ b/src/config/ecosystem.json @@ -5,10 +5,10 @@ "codeName": "AAMasters", "displayName": "Masters", "host": { - "url": "https://platform-api-dev.superalgos.org/", - "storage": "https://aadevelop.blob.core.windows.net", + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", "container": "aamasters", - "accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D" + "accessKey": "" }, "bots": [ { @@ -725,10 +725,10 @@ "codeName": "AAVikings", "displayName": "Vikings", "host": { - "url": "https://platform-api-dev.superalgos.org/", + "url": "https://demo-api-dev.superalgos.org/", "container": "aavikings", - "storage": "https://aadevelop.blob.core.windows.net", - "accessKey": "?st=2019-05-20T12%3A00%3A00Z&se=2020-05-21T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=hJuV9aEP4KVZo5z54FEF1BQtkbksfwkTJFv1FYkHFRg%3D" + "storage": "localStorage", + "accessKey": "" }, "bots": [ { @@ -832,10 +832,10 @@ "codeName": "AAMasters", "displayName": "AA Arena", "host": { - "url": "https://platform-api-dev.superalgos.org/", - "storage": "https://aadevelop.blob.core.windows.net", + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", "container": "aaplatform", - "accessKey": "?sv=2018-03-28&ss=b&srt=co&sp=rw&se=2020-01-04T00:00:00Z&st=2019-01-08T11:25:04Z&spr=https&sig=xZU1PO%2BdtVilqlZp%2BVRWW55LYl8oGZU7x4JnP%2BhMc%2FY%3D" + "accessKey": "" }, "competitions": [ { @@ -849,10 +849,10 @@ "devTeam": "AAMasters", "codeName": "PlottersROI", "host": { - "url": "https://platform-api-dev.superalgos.org/", - "storage": "https://aadevelop.blob.core.windows.net", + "url": "https://demo-api-dev.superalgos.org/", + "storage": "localStorage", "container": "aamasters", - "accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D" + "accessKey": "" }, "moduleName": "CombinedProfits", "repo": "Plotters-ROI" diff --git a/src/schema/queries/PlotterCode.js b/src/schema/queries/PlotterCode.js index f0c81fb5f..b16afd5c6 100644 --- a/src/schema/queries/PlotterCode.js +++ b/src/schema/queries/PlotterCode.js @@ -1,6 +1,8 @@ import logger from '../../utils/logger' import { FileInputType } from '../types/input' import { GraphQLString } from 'graphql' +import { getFileContent } from '../../storage/providers/MinioStorage' +import { getFileContentRemote } from '../../storage/providers/AzureStorage' export const args = { file: { type: FileInputType } } @@ -9,28 +11,33 @@ const resolve = async (parent, { file }, context) => { try { - // TODO Temporary fix for plotter and plotter pannels - if (file.storage === '' && file.accessKey === '') { - let defaultEcosystem = require('../../config/ecosystem.json') - for (let index = 0; index < defaultEcosystem.devTeams.length; index++) { - const devTeam = defaultEcosystem.devTeams[index]; - if (devTeam.codeName.toLowerCase() === file.container) { - file.storage = devTeam.host.storage - file.accessKey = devTeam.host.accessKey + let fileContent + if (file.storage === '' || file.storage === undefined) { + //TODO Add permissions + fileContent = await getFileContent(file.container, file.filePath) + } else { + // TODO Temporary fix for plotter and plotter pannels + if (file.storage === '' && file.accessKey === '') { + let defaultEcosystem = require('../../config/ecosystem.json') + for (let index = 0; index < defaultEcosystem.devTeams.length; index++) { + const devTeam = defaultEcosystem.devTeams[index]; + if (devTeam.codeName.toLowerCase() === file.container) { + file.storage = devTeam.host.storage + file.accessKey = devTeam.host.accessKey + } } } + if (file.storage === '' || file.accessKey === '') { + throw "Wrong parameters." + } + fileContent = await getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey) } - if (file.storage === '' || file.accessKey === '') { - throw "Wrong parameters." - } - - let storage = require('../../storage/providers/AzureStorage') - let fileContent = await storage.getFileContentRemote(file.container, file.filePath, file.storage, file.accessKey) return fileContent } catch (err) { - logger.error('getPlotterCode -> Error: %s', err.stack) + logger.error('getPlotterCode -> Error: %s', err) + logger.error('getPlotterCode -> Stack: %s', err.stack) throw err } } diff --git a/src/schema/types/input/File.js b/src/schema/types/input/File.js index d92d4c6f0..7b69397ae 100644 --- a/src/schema/types/input/File.js +++ b/src/schema/types/input/File.js @@ -11,7 +11,7 @@ const Type = new GraphQLInputObjectType({ container: { type: new GraphQLNonNull(GraphQLString) }, filePath: { type: new GraphQLNonNull(GraphQLString) }, storage: { type: new GraphQLNonNull(GraphQLString) }, - accessKey: { type: new GraphQLNonNull(GraphQLString) }, + accessKey: { type: GraphQLString }, fileContent: { type: GraphQLString } }), }); diff --git a/src/storage/templates/Simulator/User.Bot.Daily.js b/src/storage/templates/Simulator/User.Bot.Daily.js index 1b03337f1..7f2baca56 100644 --- a/src/storage/templates/Simulator/User.Bot.Daily.js +++ b/src/storage/templates/Simulator/User.Bot.Daily.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -19,9 +19,6 @@ let utilities = UTILITIES.newCloudUtilities(bot, logger); - const FILE_STORAGE = require('./Integrations/FileStorage.js'); - let botStorage = FILE_STORAGE.newFileStorage(); - let dataDependencies; return thisObject; @@ -113,7 +110,7 @@ function writeFiles(pTradingSystem) { tradingSystem = pTradingSystem - writeRecordsFile() + writeRecordsFile() } function writeRecordsFile() { @@ -168,7 +165,7 @@ record.maximunBalanceA + "," + record.initialBalanceB + "," + record.minimunBalanceB + "," + - record.maximunBalanceB + "]"; + record.maximunBalanceB + "]"; if (separator === "") { separator = ","; } @@ -185,7 +182,7 @@ let filePath = filePathRoot + "/Output/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -273,7 +270,7 @@ let filePath = filePathRoot + "/Output/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -350,7 +347,7 @@ let filePath = filePathRoot + "/Output/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -430,7 +427,7 @@ let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Daily" + "/" + outputPeriodLabel + "/" + dateForPath; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/src/storage/templates/Simulator/User.Bot.Market.js b/src/storage/templates/Simulator/User.Bot.Market.js index 699cfc583..52658e30e 100644 --- a/src/storage/templates/Simulator/User.Bot.Market.js +++ b/src/storage/templates/Simulator/User.Bot.Market.js @@ -1,4 +1,4 @@ -exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES) { +exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, fileStorage) { const FULL_LOG = true; const LOG_FILE_CONTENT = false; @@ -17,9 +17,6 @@ start: start }; - const FILE_STORAGE = require('./Integrations/FileStorage.js'); - let botStorage = FILE_STORAGE.newFileStorage(); - let dataDependencies; return thisObject; @@ -164,8 +161,8 @@ record.maximunBalanceA + "," + record.initialBalanceB + "," + record.minimunBalanceB + "," + - record.maximunBalanceB + "]"; - + record.maximunBalanceB + "]"; + if (separator === "") { separator = ","; } fileRecordCounter++; @@ -180,7 +177,7 @@ let filePath = filePathRoot + "/Output/" + SIMULATED_RECORDS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -258,7 +255,7 @@ let filePath = filePathRoot + "/Output/" + CONDITIONS_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -328,7 +325,7 @@ let filePath = filePathRoot + "/Output/" + STRATEGIES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { @@ -401,7 +398,7 @@ let filePath = filePathRoot + "/Output/" + TRADES_FOLDER_NAME + "/" + "Multi-Period-Market" + "/" + outputPeriodLabel; filePath += '/' + fileName - botStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); + fileStorage.createTextFile(bot.devTeam, filePath, fileContent + '\n', onFileCreated); function onFileCreated(err) { diff --git a/src/storage/templates/TradingBot/this.bot.config.json b/src/storage/templates/TradingBot/this.bot.config.json index 9074de4d5..c3d22f52e 100644 --- a/src/storage/templates/TradingBot/this.bot.config.json +++ b/src/storage/templates/TradingBot/this.bot.config.json @@ -232,10 +232,10 @@ "devTeam": "AAMasters", "bot": "AABruce", "host": { - "url": "http://localhost:4100/", - "storage": "https://aadevelop.blob.core.windows.net", + "url": "https://demo-dev.superalgos.org/", + "storage": "localStorage", "container": "aamasters", - "accessKey": "?st=2019-05-21T12%3A00%3A00Z&se=2020-05-22T12%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=PsGM67klPfLjdfjymziEQEQcD5Wzy3SMcZWsTCQrhd8%3D" + "accessKey": "" }, "botVersion": { "major": 1,