Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ttu/dummy-sensor-server
REST API and Socket.io server that generates random data in sensor-like format
https://github.com/ttu/dummy-sensor-server
express nodejs socket-io
Last synced: 12 days ago
JSON representation
REST API and Socket.io server that generates random data in sensor-like format
- Host: GitHub
- URL: https://github.com/ttu/dummy-sensor-server
- Owner: ttu
- Created: 2016-06-19T14:51:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-09T04:12:02.000Z (almost 2 years ago)
- Last Synced: 2024-12-09T09:33:20.805Z (2 months ago)
- Topics: express, nodejs, socket-io
- Language: JavaScript
- Homepage: http://dummy-sensors.azurewebsites.net/
- Size: 59.6 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dummy Sensor Server
Provides random sensor-like data
* server
* Express REST API & Socket.io server
* sensors
* BL, starts new background process and keeps track of active sensors
* sensorProcess
* Background process which updates sensor's data periodically
* sensorModel
* Model for sensor
* weather
* Get weather data periodically from Darksky API## Installation
```sh
asdf install
npm install
npm run dev
``````sh
# fetch sensors
curl localhost:3000/api/sensor
# fetch single sensor data
curl localhost:3000/api/sensor/abba5
```### REST API
```
GET /api/sensor
>
["acdc1","abba5","iddqd","idkfa"]GET /api/sensor/abba5
>
{
'id': 'abba5',
'data': 24.940641212025657,
'timestamp': 1466322901825
}GET /api/weather
>
{
'latitude': 60.192059,
'longitude': 24.945831,
'time': 1479744195,
'temperature': 7.12,
'units': 'si'
}
```### Socket.io
Listen for events
* listen (expected payload: sensorId)
* replies with sensorId if sensor is found
* stop (expected payload: sensorId)
* replies with sensorId if sensor is fondWhen sensor has updated data emit message with sensor's id
## Sample client
* Listen selected sensor's data with socket.io
* Buffer data with RxJS and reduce buffer to single item
* Visualize to C3-chart## Depolyment
Deploy to fly.io.
1. Install [flyctl](https://fly.io/docs/hands-on/install-flyctl/)
1. Deploy app
```sh
fly launch
```