项目作者: xeitodevs

项目描述 :
Webserver for controlling cameras .
高级语言: JavaScript
项目地址: git://github.com/xeitodevs/pakistrano-camera-server.git
创建时间: 2018-04-29T13:00:45Z
项目社区:https://github.com/xeitodevs/pakistrano-camera-server

开源协议:

下载


Build Status

Pakistrano camera server

This software allows you to easily control Foscam
camera family via http requests through a fast and secure api gateway.

Camera driver (before you continue reading)

This is nodejs express server wraps the camera driver. This driver
is available here.
So, if you only want to control the camera from nodejs without the http interface, this is what you want.

Running the server with docker

This is the preferred approach to run the server. You will need to create a volume
to store data. Here is an example with all use cases:

I want to run my server in development mode (no authentication).

  1. docker run --rm \
  2. -v cameras_data:/home/node/app/var \
  3. -d \
  4. -p 3000:3000 \
  5. -e "NODE_ENV=development" \
  6. xeitodevs/pakistrano-camera-server:latest

I want to run my server on production, without SSL

  1. docker run --rm \
  2. -v cameras_data:/home/node/app/var \
  3. -d \
  4. -p 3000:3000 \
  5. -e "NODE_ENV=production" \
  6. -e "AUTH_TOKEN=<here your secret token>" \
  7. xeitodevs/pakistrano-camera-server:latest

I want to run my server on production, with auto self-signed certificate generated by the server.

  1. docker run --rm \
  2. -v cameras_data:/home/node/app/var \
  3. -d \
  4. -p 3000:3000 \
  5. -e "NODE_ENV=production" \
  6. -e "AUTH_TOKEN=<here your secret token>" \
  7. -e "ENABLE_SSL=1" \
  8. xeitodevs/pakistrano-camera-server:latest

I want to run my server on production, with auto self-signed certificate generated by the server, tunning the certificate attributes.

  1. docker run --rm \
  2. -v cameras_data:/home/node/app/var \
  3. -d \
  4. -p 3000:3000 \
  5. -e "NODE_ENV=production" \
  6. -e "AUTH_TOKEN=<here your secret token>" \
  7. -e "ENABLE_SSL=1" \
  8. -e "SSL_CERTIFICATE_SUBJECT_STRING=/C=US/ST=Denial/L=Springfield/O=MyOrganization/CN=www.mycam.com" \
  9. xeitodevs/pakistrano-camera-server:latest

I want to run my server on production, with my own specified certificate.

  1. docker run --rm \
  2. -v cameras_data:/home/node/app/var \
  3. -d \
  4. -p 3000:3000 \
  5. -e "NODE_ENV=production" \
  6. -e "AUTH_TOKEN=<here your secret token>" \
  7. -e "ENABLE_SSL=1" \
  8. -e "SSL_B64_CERT=$(base64 -w 0 /path/to/your/server.cert)" \
  9. -e "SSL_B64_KEY=$(base64 -w 0 /path/to/your/server.key)" \
  10. xeitodevs/pakistrano-camera-server:latest

Docker boot behaviour

The next environment variables are only intended for the first-time generation of
camera database and certificates. They will become unnecessary after first boot since
all that data is now available in the generated data volume.

  • SSL_CERTIFICATE_SUBJECT_STRING
  • SSL_B64_CERT
  • SSL_B64_KEY

    Exposing the API

    Api has two main purpose methods
  • The camera CRUD
  • The camera control command endpoint, with the following available commands
    • startMoveRight
    • startMoveLeft
    • centerCamera
    • stopAxes
    • startMoveUp
    • startMoveDown
    • startMoveBottomRight
    • startMoveBottomLeft
    • startMoveUpRight
    • startMoveUpLeft
    • startHorizontalPatrol
    • stopHorizontalPatrol
    • startVerticalPatrol
    • stopVerticalPatrol
    • activateIrView
    • deactivateIrView

Authentication

When not in development, this server uses bearer token authentication,
so don`t forget to set your compliant authorization with RFC6750

Camera registration

  1. curl --request POST \
  2. --url http://localhost:3000/cameras \
  3. --header 'content-type: application/json' \
  4. --data '{
  5. "name": "labcamera",
  6. "host": "10.0.8.4",
  7. "user": "admin",
  8. "password": "admin"
  9. }'

Camera listing

  1. curl --request GET \
  2. --url http://localhost:3000/cameras \
  3. --header 'content-type: application/json'

Getting camera

  1. curl --request GET \
  2. --url http://localhost:3000/cameras/labcamera \
  3. --header 'content-type: application/json'

Camera ping

  1. curl --request GET \
  2. --url http://localhost:3000/cameras/labcamera/ping \
  3. --header 'content-type: application/json'

Get camera snapshot

  1. curl --request GET \
  2. --url http://localhost:3000/cameras/labcamera/snapshot \
  3. --header 'content-type: application/json'

Get camera video stream

  1. curl --request GET \
  2. --url http://localhost:3000/cameras/labcamera/video-stream \
  3. --header 'content-type: application/json'

Send one command to an specific camera (see the command list above)

  1. curl --request POST \
  2. --url http://localhost:3000/cameras/labcamera/control \
  3. --header 'content-type: application/json' \
  4. --data '{
  5. "command": "startMoveRight"
  6. }'

Update one camera.

  1. curl --request PUT \
  2. --url http://localhost:3000/cameras/labcamera \
  3. --header 'content-type: application/json' \
  4. --data '{
  5. "name": "labcamera",
  6. "host": "10.0.8.2",
  7. "user": "admin2",
  8. "password": "admin2"
  9. }'

Delete one camera

  1. curl --request DELETE \
  2. --url http://localhost:3000/cameras/labcamera \
  3. --header 'content-type: application/json'

Delete all cameras

  1. curl --request DELETE \
  2. --url http://localhost:3000/cameras \
  3. --header 'content-type: application/json'

How to run tests

  • Run ALL tests
    1. npm test
  • Run tests in watch mode
    1. npm run-script test:watch
  • Run only unit tests
    1. npm run-script test:unit