Record Service
This service is where to receive audio files from providers, store it to provide webphone-service and other services in the system.
I. Functionality
- Get records from providers and update record url in call log
- Store and provide record files
- Upload record to digital ocean space
- Authorize via a username and a password, exemplifying Basic Access Authentication
1. syncRecord cron
- This cron use Rsync to get mp3 files from each pbx and save mp3 files in record directory
2. updateLink cron
- This cron search and update empty recordUrl of connected calllogs
- This cron have two Modes
RECORD_MODE = 1, This mode search for all connected calllogs which have empty recordUrl in 24 hours then update recordUrl ( Digital Ocean Link )
RECORD_MODE = 2, This mode search for all connected calllogs then update mp3 link from digital ocean
3. uploadRecord cron
- This cron upload all mp3 files in record directory to Digital Ocean then delete all uploaded files
4. Daily/ Monthy/ Weekly Cron
- This Cron export all calllog info in Dayly/Weekly/ Monthy to exel then send to customer by using smtp
II. Packages
1. Dependencies
- @ffmpeg-installer/ffmpeg - Platform independent binary installer of FFmpeg for node projects @ffmpeg-installer/ffmpeg
- Await-to-js - Async await wrapper for easy error handling Await-to-js
- Aws-sdk - AWS SDK for JavaScript in Node.js Aws-sdk
- Axios - Promise based HTTP client for the browser and node.js Axios
- Babel-polyfill - Provides polyfills necessary for a full ES2015+ environment Babel-polyfill
- Babel-preset-es2015 - Babel preset for all es2015 plugins Babel-preset-es2015
- Babel-preset-stage-0 - Babel preset for stage 0 plugins Babel-preset-stage-0
- Babel-register - Babel require hook Babel-register
- Bluebird - Full featured Promises/A+ implementation with exceptionally good performance Bluebird
- Body-parser - Node.js body parsing middleware Body-
- Child_process - The child_process module provides the ability to spawn child processes in a manner that is similar, but not identical, to popen(3) Child_process
- Crom - A simple cron-like job scheduler for Node.js Crom
- Cron - Cron is a tool that allows you to execute something on a schedule Cron
- Dotenv - Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env Dotenv
- Express - Fast, unopinionated, minimalist web framework for node Express
- Fluent-ffmpeg - A fluent API to FFMPEG Fluent-ffmpeg
- Formidable - A Node.js module for parsing form data, especially file uploads Formidable
- Jsonfile - Easily read/write JSON files Jsonfile
- Mongodb - The official MongoDB driver for Node.js Mongodb
- Morgan - HTTP request logger middleware for node.js Morgan
- Nodemailer - Send e-mails from Node.js Nodemailer
- Objects-to-csv - Convert objects into CSV format Objects-to-csv
- Split-file - Split a file into multiple chunks Split-file
- Ssh-exec - SSH execution commands Ssh-exec
- Winston - A logger for just about everything Winston
- Zip-a-folder - Zip a folder and its contents Zip-a-folder
2. Dev dependencies
- Nodemon - Simple monitor script for use during development of a node.js app Nodemon
III. Database
1. ERD

2. Database schema
Pbx provides information of a contact. Indeed, every call center has a distinct collection to store their contacts. The collection names follow the format contact_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| name | string | First name of the contact |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
| _v | string | Schema version |
Domain provides information of a contact. Indeed, every call center has a distinct collection to store their contacts. The collection names follow the format contact_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| name | string | First name of the contact |
| idTenant | string | Tenant Id |
| server | string | Server address |
| apiKey | string | API key |
| stt | string | Status domain |
| time | string | |
| url_api | string | |
| key_api | string | |
| secret_api | string | |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
| _v | string | Schema version |
IV. Source Tree
├── .babelrc
├── .pbx-env ## Multi Pbx
│ ├── gc03.env
│ └── gc04.env
├── API.md
├── config
│ ├── access.js
│ ├── authorization.js
│ ├── aws.js
│ ├── credentials.js
│ ├── host.js
│ ├── mongodb.js
│ ├── pbx.js
│ └── pbxlog.js
├── external-api ## Tel4 API
│ └── tel4vn.js
├── index.js
├── lib
│ ├── access.js
│ ├── logger.js
│ ├── monthlyRecord.js
│ ├── record.js
│ ├── schedule.js
│ ├── syncRecord.js
│ ├── updateLink.js
│ └ ── uploadRecord.js
├── middleware
│ └── authorization.js
├── model
│ ├── domain.js
│ └── pbx.js
├── package.json
├── route
│ ├── domain.js
│ ├── pbx.js
│ ├── record.js
│ └── v1
│ ├── domain.js
│ ├── index.js
│ ├── pbx.js
│ └── record.js
├── server.js
├── sourcetree.js
└── template
└── monthlyRecord.html
V. Installation
1. Install dependencies
1.1 Install ffmpeg
// For Ubuntu 16.04
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ffmpeg
1.2. Install project
- Clone project:
git clone https://gitlab.com/gcalls-opensource/gcallsback.git
- Change dir into recordService folder
cd recordService
- Install packages:
npm install
-
Start service:
-
run in development
npm run dev- run in production
npm install -g pm2
npm start
-
VI. Endpoint
Please visit API documentation for more details
VII. Author
- Duong Cat Hung Vuong vuong.duong@gcalls.co💣 - Fullstack engineer at Gcalls Vietnam Pte Ltd