Basic Restfull API build on top of koa.js framework to handle a Raspberry Pi 3 model B with a expansion board
- Clone the repo
https://github.com/alanbueno/rasp-node-blink
- Create an SentryProject https://sentry.io/
- Run
npm install
oryarn install
- Create your .env file
- Run
npm start
oryarn run start
Create a .env file (in the root of the project) with the env variables
HOST=customHost (default: 0.0.0.0)
PORT=customPort (default: 3001)
BASE_PATH=customBasePath
[email protected]/token
Once the app is ready n running, use any HTTP(s) client to make a request:
$npm start
You can set port on config file, if not, default is 3001.
Examples:
- http://localhost:3001/
- Method: GET
- Host: http://localhost:3001
- Path: '/'
Shoud return just:
{
"version": "0.1.0",
"uptime": 31.523
}
- http://localhost:3001/ping
- Method: GET
- Host: http://localhost:3001
- Path: '/ping'
Shoud return just:
pong
- http://192.168.0.17:3001/toggleRelay/2
- Method: PATCH
- Host: http://yourRaspIp:3001
- Path: '/toggleRelay/:idRelay'
Shoud return just:
{
"state": "on"
}
Or:
{
"state": "off"
}