The backend is a nodejs
application packaged in a docker
container self built by gitlab CI and pushed to the gitlab container registry.
The docker-compose
file in this repository also has the database engine within here for easy access.
All thats required is docker(1)
and docker-compose(1)
(latest versions recommended) installed. You may follow the guide for steps how to do so.
# First two steps may no longer be needed
# Login as user nolim1t
docker login registry.gitlab.com -u nolim1t
# Enter personal access token as password
docker pull registry.gitlab.com/nolim1t/airdeveloppa-backend:latest
# Pull specific version
docker pull registry.gitlab.com/nolim1t/airdeveloppa-backend:v0.1.16
Some sample mongodb commands
docker exec -it mongodb mongo -uroot -ppasssword
Endpoint: https://backend.airdeveloppa.services/1/register
This endpoint automatically creates an authentication token for a device or checks to see if the authentication token exists. The purpose of this is to identify users in the system
This endpoint also lets an existing device re-validate an authentication token.
device_id
(required. This should be a uuid generated by the device)token
(not required if the uuid generated by the device exists, it should be kept private)
Endpoint: https://backend.airdeveloppa.services/1/list
lat
(required. eg. 18.798444546939923)lng
(required. eg. 98.96888142026467)distance
(required. in meters)
curl "https://backend.airdeveloppa.services/1/list?distance=20000&lat=18.798444546939923&lng=98.9688814202646"
Endpoint: https://backend.airdeveloppa.services/1/balance
This endpoint shows the users balance in satoshis.
token
(Required)
Endpoint: https://backend.airdeveloppa.services/1/withdraw
token
(required. account authorization token)invoice
(required. Lightning invoice for the withdraw request)
Endpoint: https://backend.airdeveloppa.services/1/verify
token
(required. This is the authentication token. You should keep this safe)id
(required. This is the device UUID)fakeVerify
(for testing. If you set this to false this will simulate a fail response)
Endpoint: https://backend.airdeveloppa.services/1/deviceinfo/UUID
- Requires a
uuid
as part of the GET parameters - Returns the business associated with the device along with the device(s) as the response
Endpoint: https://backend.airdeveloppa.services/1/device_push
- Must send a
Content-Type: application/json
header - Must send a JSON object with the following parameters
deviceid
, andAQI
- Copy
env-dist
to.env
before startingdocker-compose.yml
. Configure the defaults is recommended - Have a
PERSONALTOKEN
variable set up in gitlab - When releasing push a tag
- Ensure that there is a
mongodb
directory available in the route.
Endpoint: POST https://backend.airdeveloppa.services/1/business
token
- Admin authenticationbusinessname
businessaddress
businesscity
(eg. Chiang Mai)businessregion
(eg. Chiang Mai)businesscountry
(eg. TH)lat
- latitude of businesslng
- longitude of busines
# Example
curl "https://backend.airdeveloppa.services/1/business" \
-H "Content-type: application/json" \
-d '{"token": "security token", "businessname": "Corner Bistro & Burrito Squad", "businessaddress": "8, 8 Ratchaphuek Alley", "businesscity": "Chiang Mai", "businessregion": "Chiang Mai", "businesscountry": "TH", "lat": 18.798663671992312, "lng": 98.97526790697208}'
Endpoint: POST https://backend.airdeveloppa.services/1/deviceregister
token
- Admin authenticationbusinessid
- to associate a device with a business.devicebounty
- Bounty in satoshisdevicelabel
- freeform label of the devicedevicelocation
- freeform location of device
Showing full response
curl "https://backend.airdeveloppa.services/1/deviceregister" \
-H "Content-type: application/json" \
-d '{"token": "", "businessid": "70c59c79-66f9-4c1f-938d-91c5dc2fd208", "devicelocation": "Upstairs", "devicelabel": "Corner Bistro test"}'
Showing device id in response only
curl "https://backend.airdeveloppa.services/1/deviceregister" \
-H "Content-type: application/json" \
-d '{"token": "", "businessid": "70c59c79-66f9-4c1f-938d-91c5dc2fd208", "devicelocation": "Upstairs", "devicelabel": "Corner Bistro test"}' | jq .result.deviceid
Endpoint: POST https://backend.airdeveloppa.services/1/setdeviceattr
token
- Admin authentication (for now)deviceid
- Required field. Specify the device to modifydevicelabel
- Optional devicelabeldevicelocation
- Optional devicelocationdevicebounty
- Optional devicebountydevicestatus
- - Optional devicestatus
curl "https://backend.airdeveloppa.services/1/setdeviceattr" \
-H "Content-type: application/json" \
-d '{"token": "", "deviceid": "fb450036-2acd-4a34-93cc-cdc90ca60b9b", "devicelabel": "new label"}'
node -e 'var crypto = require("crypto"); var adminkey = crypto.createHash("sha256").update(crypto.createHash("sha256").update("admin" + "||" + (new Date().getTime()).toString()).digest("hex")).digest("hex"); console.log(adminkey);'
curl "https://backend.airdeveloppa.services/1/validatedevice" \
-H "Content-type: application/json" \
-d '{"businessid": "", "deviceid": ""}'