Copcast Server is part of the Copcast solution to help improve police accountability using mobile phones to record the video and the audio and register their GPS location.
Copcast Server is a server API developed with Node.js and Express
First, install Node.js in your development machine. We are using, currently, version 0.10.40.
Then make sure you have the following softwares installed:
- ImageMagick
- ffmpeg
- PostgreSQL server and development files
- gcc, gcc-c++ and make
- bzip2
IMPORTANT: use the version 2.6.8 of ffmpeg. We will test it with the version 3.x in the following months.
First make sure you have NodeJS and NPM properly installed (check http://nodejs.org for help).
npm install -g forever nodemon express sequelize-cli
npm install
The server requires a PostgreSQL database.
First, create 2 database users, <DB_OWNER> and <DB_USER>. The first will be the owner of the database and user for administrative purposes, while the second, a less privileged one, will be used by the application.
CREATE USER <DB_OWNER> WITH PASSWORD '<PWD>';
CREATE USER <DB_USER> WITH PASSWORD '<PWD>';
CREATE DATABASE <DBNAME> WITH OWNER <DB_USER> ENCODING 'UTF8';
Next, setup your configuration files. Copy the following files from lib/config/template to config/:
- development.json
- common.json
Now edit the connection string and enter your database parameters, like username, password, database and host in "development.json".
Note: In "development.json" use the credentials of <DB_USER>.
Next, at the project root, initialize your database:
psql -U <DB_OWNER> -f copcast-db.sql
NODE_ENV=development sequelize db:migrate --url 'postgres://<DB_OWNER>:<PWD>@<HOST>:5432/<DBNAME>'
The video files are encrypted before being stored. If you want to change the password or the salt, run the following script:
NODE_ENV=development node cryptoConfigGenerator.js
The output is a JSON fragment to be stored into "development.json". The number of partitions allows the password to be constructed from the input of multiple users, each having its own password. For production mode, it is advised to remove the "key" subsection under "crypto".
Finally, start your application:
NODE_ENV=development node app.js
Finally, you have to create the master user. Please access the following url:
http://<LOCALHOST>:3000
Remember to change to the actual server address.
- Create a production.json file at config/
- Set your database connection parameters and cryptography parameters (without the "key" entry).
- Run it (the passwords must be entered at the same order as previously configured):
NODE_ENV=production node app.js