This is the REST API component of a three-parts project where an API, an arduino and a mobile app communicate together in order to enable users to remotely control the power state of their desktop computer(s).
- Download and install golang
- Clone the repository:
git clone https://github.com/sqrrrrl/pc-power-api.git
- Navigate to the project directory and download the dependencies:
go mod download
- Build the project:
go build -v -o ./outputDirectory/appName ./src/app
Some environment variables need to be set for the API to work properly:
PORT
: The port which the API should listen to
JWT_SECRET
: A random 32 characters string used to generate the authentication tokens
DBTYPE
: Either sqlite or mysql
DBNAME
: The name of the database
The environment variables required to use mysql:
DBUSER
: The username of the database.
DBPASS
: The password of the database.
DBHOST
: The ip address or domain of the database.
DBPORT
: The port of the database.
Once the environment is set the API can be started by executing the compiled project:
./outputDirectory/appName
Distributed under the GPL-3.0 license