Skip to content

Latest commit

 

History

History
109 lines (70 loc) · 3.5 KB

README.md

File metadata and controls

109 lines (70 loc) · 3.5 KB

Build Status

Copcast Server

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

Dev Installation

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.

Building

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

Database

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>'

Cryptography

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".

Running

Finally, start your application:

NODE_ENV=development node app.js

First User

Finally, you have to create the master user. Please access the following url:

http://<LOCALHOST>:3000

Remember to change to the actual server address.

Deployment

  1. Create a production.json file at config/
  2. Set your database connection parameters and cryptography parameters (without the "key" entry).
  3. Run it (the passwords must be entered at the same order as previously configured):
NODE_ENV=production node app.js