- Micro service to get data from config/index.js ( url ) and store it to the DB
- Other part of the project utilize db data and create aggregate collection from it.
$ git clone
$ cd project_folder
$ npm install OR npm ci (same versions)
npm start - get data
npm run start:debug - get data verbose mode
-------------------
npm run start:aggregate - generate aggregate
-------------------
npm run start:mongodb - start local mongoDB
With mocha, chai, sinon, nock, mongodb-memory-server & nyc - reporter
npm test
Start locally without install mongoDb / use inMemoryMongoDB
npm run start:mongodb
run on every minutes
*/1 * * * * /../../index.js >> /../../logs/index.log 2>&1
*/1 * * * * /usr/local/bin/node /../../index.js >> /../../logs/index.log 2>&1
run on every 15 minutes
*/15 * * * * /../../agr.js >> /../../logs/agr.log 2>&1
$ ./commands/list.js - list saved data
$ crontab -e
*/1 * * * * /usr/local/bin/node /var/www/html/index.js >> /var/www/html/projFolder/logs/cron.log
- Go to url config.url and get content
- Split and format content per pairs/symbols
- Save raw rates at collection RRATES
const rawSchema = new Schema({
sid: Number,
value: Number,
ohlc: String,
time: Date,
created: {type: Date, default: Date.now}
})
- Save into RATES
- exit with success (0) or fail(1)
-
Tune aggregate find query to be more explicit/strict - created between date1 and date2 db.collection({created: {$gt: startDate, $lt: endDate}})
-
Extend cralwer action use register to *** to get more pairs
-
change OHLC(Open/High/Low/Close) into ARRAY from string !!!
-
Think about collection indexes ...
-
for testing start local MongoInMemory server and use it.
-
CLI redirection Get output from one command and pass it to another.
-
Stop trace changes for file
git update-index --assume-unchanged FILE_NAME -
require('folder') - require order is : index.js then index.json if both of them are present
ONLY COMMAND LINE...
C1=`./commands/index.js` && ./commands/get.js $C1
*** Mongoose queries which did not return promise
Model.deleteMany()
Model.deleteOne()
Model.find()
Model.findById()
Model.findByIdAndDelete()
Model.findByIdAndRemove()
Model.findByIdAndUpdate()
Model.findOne()
Model.findOneAndDelete()
Model.findOneAndRemove()
Model.findOneAndUpdate()
Model.replaceOne()
Model.updateMany()
Model.updateOne()
period = (new Date()).getTime(); period = parseInt(period / 1800000); //hours in year