This software allows you to easily control Foscam camera family via http requests through a fast and secure api gateway.
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.
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:
docker run --rm \
-v cameras_data:/home/node/app/var \
-d \
-p 3000:3000 \
-e "NODE_ENV=development" \
xeitodevs/pakistrano-camera-server:latest
docker run --rm \
-v cameras_data:/home/node/app/var \
-d \
-p 3000:3000 \
-e "NODE_ENV=production" \
-e "AUTH_TOKEN=<here your secret token>" \
xeitodevs/pakistrano-camera-server:latest
docker run --rm \
-v cameras_data:/home/node/app/var \
-d \
-p 3000:3000 \
-e "NODE_ENV=production" \
-e "AUTH_TOKEN=<here your secret token>" \
-e "ENABLE_SSL=1" \
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.
docker run --rm \
-v cameras_data:/home/node/app/var \
-d \
-p 3000:3000 \
-e "NODE_ENV=production" \
-e "AUTH_TOKEN=<here your secret token>" \
-e "ENABLE_SSL=1" \
-e "SSL_CERTIFICATE_SUBJECT_STRING=/C=US/ST=Denial/L=Springfield/O=MyOrganization/CN=www.mycam.com" \
xeitodevs/pakistrano-camera-server:latest
docker run --rm \
-v cameras_data:/home/node/app/var \
-d \
-p 3000:3000 \
-e "NODE_ENV=production" \
-e "AUTH_TOKEN=<here your secret token>" \
-e "ENABLE_SSL=1" \
-e "SSL_B64_CERT=$(base64 -w 0 /path/to/your/server.cert)" \
-e "SSL_B64_KEY=$(base64 -w 0 /path/to/your/server.key)" \
xeitodevs/pakistrano-camera-server:latest
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
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
When not in development, this server uses bearer token authentication, so don`t forget to set your compliant authorization with RFC6750
curl --request POST \
--url http://localhost:3000/cameras \
--header 'content-type: application/json' \
--data '{
"name": "labcamera",
"host": "10.0.8.4",
"user": "admin",
"password": "admin"
}'
curl --request GET \
--url http://localhost:3000/cameras \
--header 'content-type: application/json'
curl --request GET \
--url http://localhost:3000/cameras/labcamera \
--header 'content-type: application/json'
curl --request GET \
--url http://localhost:3000/cameras/labcamera/ping \
--header 'content-type: application/json'
curl --request GET \
--url http://localhost:3000/cameras/labcamera/snapshot \
--header 'content-type: application/json'
curl --request GET \
--url http://localhost:3000/cameras/labcamera/video-stream \
--header 'content-type: application/json'
curl --request POST \
--url http://localhost:3000/cameras/labcamera/control \
--header 'content-type: application/json' \
--data '{
"command": "startMoveRight"
}'
curl --request PUT \
--url http://localhost:3000/cameras/labcamera \
--header 'content-type: application/json' \
--data '{
"name": "labcamera",
"host": "10.0.8.2",
"user": "admin2",
"password": "admin2"
}'
curl --request DELETE \
--url http://localhost:3000/cameras/labcamera \
--header 'content-type: application/json'
curl --request DELETE \
--url http://localhost:3000/cameras \
--header 'content-type: application/json'
- Run ALL tests
npm test
- Run tests in watch mode
npm run-script test:watch
- Run only unit tests
npm run-script test:unit