Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.68 KB

DEVELOP_WEB.md

File metadata and controls

46 lines (35 loc) · 1.68 KB

Local web server deployment guide

Downloads

  1. Install PostgreSQL.
  2. Install NodeJS.
  3. Clone this repository (e.g. enter git clone https://github.com/Happytreat/dynalite.git in your command-line terminal).
  4. Change directory to the newly created dynalite directory by entering cd dynalite.

Database setup

  1. Log into psql by entering psql -U username -d database. Replace the fields accordingly (e.g. psql -U postgres -d postgres).
  2. Execute setup.sql by running the command \i setup.sql.
  3. Exit psql by entering \q.

NodeJS setup

  1. Change directory to the src folder by entering the command cd src.
  2. Install the required packages by entering npm install.
  3. Create a file named .env in the current directory (refer to .env.backup).
  4. Open .env and enter the following:
DATABASE_URL=postgres://<username>:<password>@<hostname>:<port>/<database_name>
ALGORITHM=<algorithm>
KEY=<key>

Replace the fields in < > accordingly.

Example:

DATABASE_URL=postgres://postgres:password@localhost:5432/postgres
ALGORITHM=aes-128-cbc
KEY=helloWorldSecureKey21
  • 5432 is the default port for PostgreSQL

Local server setup

  1. Run this project on your local server by using npm start.
  2. Stop the server by using CTRL + C.

Testing

  1. To test Dynalite without a Raspberry Pi, refer to COAP-CLI. An example command would be: coap post coap://localhost/ -p "Hello COAP".
  2. Dynalite receives POST COAP messages at coap://localhost/ which are stored in a PostgreSQL table.
  3. Dynalite displays these stored messages at http://localhost:3000/.