master
BioProAPIServer
Setup postgresql
Installation
sudo apt-get install postgresql libpq-dev postgresql-client postgresql-client-common
Switch to the Postgres user to configure the database
sudo su postgres
Create a database user 'biopro' with password 'BioProControlBox'
createuser biopro -P --interactive
Postgres command (type psql first to connect postgres)
#Enter postgresql
psql
#Find databases
\l
#Find tables
\dt
# Create new database and table if you need
create database test
test=> create table people (name text, company text)
Run apiServer on device
Clone project
git clone https://gitlab.com/bioproscientific/bioproapiserver.git
Change config port
cd ~/bioproapiserver/src
vim config.js
change the code following as:
/*
change apiserver port to postgres port, 54321 --> 5432 (default)
*/
export const pgDB = {
host: '127.0.0.1',
port: 54321, // -----------------> 5432
username: 'biopro',
password: 'BioProControlBox',
database: 'postgres'
}
Init setup project && build dist app
cd ~/bioproapiserver
npm install
npm run build
Auto run program when pi-start
sudo vim /etc/rc.local
add the code following as:
nohup node /home/pi/bioproapiserver/dist/app.js > /home/pi/.api_server.out &
Localhost develop
Localhost test port binding (your device:54321 -> raspberrypi:5432)
ssh -NL 54321:localhost:5432 pi@your-pi-ip
Run apiServer on your localhost (remember binding port first)
git clone https://gitlab.com/bioproscientific/bioproapiserver.git
cd bioproapiserver
npm install
npm run start
References
https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi
Languages
JavaScript
95.1%
Python
4.5%
Dockerfile
0.3%