Dengue Lamps & Minimal covering circle API
-
v0.9.3 (Todo Features)
- Add Tables: lamps_meta, notification
- Use pm2 deploy
-
v0.9.2.4 (Todo Features)
- Modify
- Modify Point Size Function
- Add
- get counts just by hour
- Modify
-
v0.9.2.3 (Master Branch)
- Refactoring
- request validation error handling
- Add
- get counts by hashID (formatByDate)
- Return Body when Put Item
- Fix
- cannot Get lamps By too short wrong hashID
- Return 400 when Post with null value
- change GET Lamps attributes constantly
- Refactoring
-
v0.9.2.2
- Add Zapper Front end display
- Set lamp data No return Wifi code
- Set 6 characters lamp hash validation in post comment
-
v0.9.2.1
- Fix 0.9.2 formatByDate error
- Set sample admin pw to env variable
-
v0.9.2 (found query error, use 0.9.2.1)
-
Auth
- New Tables: user, roles
- New Session Auth of post, put, delete request
-
Support
- Add get counts format by hour and limit days
- Add post new comment by hash id
- Add get lamp by hash id
-
-
v0.9.1
- With RESTFul API of Lamps, Places, Counts, States, Mcc, Rules, Comments
- With Lamp MQTT message Subscribe
- Node.js: '^7.6.0'
- PostgreSQL: '^9.3'
$ yarn install // or npm install
- Create Dev DB & user. Check here
- Setup your environment variables
DATABASE
,USER
,PASSWORD
in config/lampDevConfig.js & config/lampProdConfig.js
It will Drop Dev tables if these already exist
$ node config/dbInitialize.js
- Use dev database
$ npm start
// or use pm2
$ pm2 start ecosystem.config.js
- Test Each RESTful API
$ npm test
Use Production Database
$ export NODE_ENV=production
$ npm run prod
// or
$ pm2 start ecosystem.config.js --env production
$ npm install -g pm2
$ cd mqttSub
$ pm2 start ecosystem.config.js --only Lamp_Sub
- check Mqtt Log
$ pm2 logs Lamp_Sub
Check API Document Site
- Modify api.apib
- Generate api doc site
$ npm install -g aglio
$ npm run doc
- v0.9.1 Tables(7)
Table Name | Description | Remarks |
---|---|---|
lamps | 捕蚊燈相關資料 | |
lamp_places | 捕蚊燈部署店家相關資料 | |
lamp_counts | 捕蚊燈捕獲數目 | |
lamp_states | 捕蚊燈狀態 | |
lamp_mcc | 密集處包含圓 | |
lamp_mcc_rules | 包含圓產生規則 | |
lamp_comments | 捕蚊燈店家留言 |
Field | Type | Null | Key | Default | Remarks |
---|---|---|---|---|---|
lamp_id | varchar(25) | PRI | |||
lamp_hash_id | varchar(64) | SHA-256 with secret | |||
lamp_location | [double precision] | ||||
lamp_deployed_date | date | YES | NULL | 捕蚊燈部署日期 | |
lamp_wifi_ssid | varchar(25) | YES | NULL | ||
lamp_wifi_password | varchar(25) | YES | NULL | ||
place_id | integer | IND | |||
created_at | timestamp | ||||
updated_at | timestamp |
Keyname | Type | Field |
---|---|---|
lamp_id | PRIMARY | lamp_id |
place_id | INDEX | place_id |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
place_id | integer | PRI | auto_increment | |||
place_name | varchar(25) | |||||
place_address | varchar(50) | |||||
place_contact_person | varchar(10) | YES | NULL | 聯絡人 | ||
place_phone | varchar(25) | YES | NULL | |||
created_at | timestamp | |||||
updated_at | timestamp |
Keyname | Type | Field |
---|---|---|
place_id | PRIMARY | place_id |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
count_id | integer | PRI | auto_increment | |||
lamp_id | varchar(25) | IND | ||||
counts | integer | |||||
created_at | timestamp | IND |
Keyname | Type | Field |
---|---|---|
count_id | PRIMARY | count_id |
lamp_id | INDEX | lamp_id |
created_at | INDEX | created_at |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
state_id | integer | PRI | auto_increment | |||
lamp_id | varchar(25) | IND | ||||
lamp_state | integer | IND | 捕蚊燈狀態: 2: 檢查中, 1: 異常待查, 0: 正常 | |||
lamp_check_date | date | YES | NULL | 檢查日期 | ||
lamp_check_person | varchar(10) | YES | NULL | 檢查者 | ||
state_description | text | YES | NULL | 異常狀況 | ||
state_reason | text | YES | NULL | 異常原因 | ||
created_at | timestamp | |||||
updated_at | timestamp |
Keyname | Type | Field |
---|---|---|
state_id | PRIMARY | state_id |
lamp_id | INDEX | lamp_id |
lamp_state | INDEX | lamp_state |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
mcc_id | integer | PRI | auto_increment | |||
mcc_keys | [varchar(25)] | 包含圓邊界點 | ||||
mcc_points | [varchar(25)] | 包含圓包含點 | ||||
mcc_center | [double] | 包含圓中心座標 | ||||
rule_id | integer | |||||
created_at | timestamp | IND |
Keyname | Type | Field |
---|---|---|
mcc_id | PRIMARY | mcc_id |
created_at | IND | created_at |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
rule_id | integer | PRI | auto_increment | |||
timeline_upper_limit | integer | 幾天內 | ||||
distance_lower_limit | integer | 圓半徑 | ||||
points_lower_limit | integer | 最少點數目 | ||||
counts_lower_limit | integer | 單一點最少捕獲數目 | ||||
created_at | timestamp | |||||
updated_at | timestamp |
Keyname | Type | Field |
---|---|---|
rule_id | PRIMARY | rule_id |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
comment_id | integer | PRI | auto_increment | |||
lamp_id | varchar(25) | IND | ||||
comment_content | text | |||||
created_at | timestamp | 留言日期 |
Keyname | Type | Field |
---|---|---|
comment_id | PRIMARY | comment_id |
lamp_id | INDEX | lamp_id |
Field | Type | Null | Key | Default | Remarks |
---|---|---|---|---|---|
user_id | varchar(15) | PRI | |||
varchar(64) | UNI | ||||
password | varchar(64) | Bcrypt with Salt | |||
first_name | varchar(15) | YES | NULL | ||
last_name | varchar(15) | YES | NULL | ||
phone | varchar(25) | YES | NULL | ||
mail_subscription | boolean | TRUE | |||
role_id | varchar(25) | IND | |||
created_at | timestamp | ||||
updated_at | timestamp |
Keyname | Type | Field |
---|---|---|
user_id | PRIMARY | user_id |
role_id | INDEX | role_id |
Field | Type | Null | Key | Default | Extra | Remarks |
---|---|---|---|---|---|---|
role_id | varchar(25) | PRI | ||||
role_description | TEXT | |||||
role_permissions | TEXT | JSON Stringify | ||||
created_at | timestamp | |||||
updated_at | timestamp |
Keyname | Type | Field |
---|---|---|
role_id | PRIMARY | user_id |
MIT © Pochun