A simple Node.js script to take CDR files generated by a PBX (3CX is the target) and pump them into MySQL.
This script will watch a folder on your file system, and upon a file appearing will attempt to parse it as a CSV/CDR file. Upon successful completion of the parse and SQL insert it will then delete the CDR file.
Open the config.js file and fill in the parameters with ones that match your own environment. Note that file system paths in Windows need to be appropriately escaped (\ becomes \).
In the fields area you need to ensure that you have added one line per field you export in your CDR. You don't have to store them all in MySQL, but you do need to make provision them them to exist in the config.
npm run main.js
Have the system run a query beforehand to check if the CDR record to be inserted already exists. In the meantime you may as well just make a MySQL constraint to stop this from happening.
This is my first Node.js application, and to be honest I don't really know what I'm doing. Tips, advice, bug reports, etc are all very welcome.