GithubHelp home page GithubHelp logo

kldavis4 / copcast-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cbmsc-diti/mogi-server

1.0 3.0 1.0 2.06 MB

Server API for the Project Copcast/SmartPolicing solution

License: GNU General Public License v2.0

JavaScript 91.85% PLpgSQL 6.10% HTML 2.01% CSS 0.03%

copcast-server's Introduction

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

You can check our general requirements here.

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:

  • 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/config

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

HTTPS Pinning

This note is applicable if server is configured to use HTTPS. For security, CopCast Android app checks for https certificates from server and display error message if https pinning failed. For proper functioning of android app, please include intermediate CA and root CA certificates used for signing server's certificate in assets folder of android app.

Production Installation

Check our production installation page

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.