In order to run locally you need to install and have running MongoDB and Node.js as services on your machine. Details how to connect to MongoDB you can find in config.js file which is in root directory of the Micro-service.
Other important packages(best installed globally) that you need are gulp, mocha, nodemon
After you clone or checked out from Gitlab repository, go to the project's directory and run commands
$ npm install (this will install all dependencies needed)
$ npm start (this will start the server)
or
$ nodemon
or
$ gulp
$ npm test
Info: https://github.com/Unitech/pm2, http://pm2.keymetrics.io/
Ensure that package pm2 is installed on your environment.
Important file is ecosystem.json, which holds configuration for app:
- watcher for files, whenever there is change within a file restart server
- which files not to watch
- make clustering and load balancer
- set the environments
In order to check state of the app or start the app use this steps:
$ cd /your-folder/
$ pm2 list (check if there is anything running, if not go to 3. step)
$ pm2 start ecosystem.json (start server and cronjob)
If you change the ecosystem.json file do the following
$ cd /your-folder/
$ pm2 delete ecosystem.json
$ pm2 start ecosystem.json
Devices collection and indexing:
const DeviceSchema = new Schema({
name: String,
data: Schema.Types.Mixed,
date: {type: Date, default: Date.now, get: transformDate}
});
Home route
Route to get form for reports
Route to post data to backend and get in response Excel file
Route to start scraping data from website
Route to get all data from database and show them in table to the user
Route to get data of device
Route to edit data of device
Route to delete device
Invoked when health check is needed Route with information about the health of MongoDB and Scrape links, test if we can connect to those services