This repository contains source code of an IoT system developed for a Unisannio exam:
- information integration layer program code: server exposing REST API, written in Node.js
- physical layer program code: to be loaded on the microcontroller (NUCLEO-F401RE), written in C++
- STM32 NUCLEO-F401RE
- X-NUCLEO-IKS01A2
- ESP8266
The following instructions are for the server part:
# Clone the project
git clone https://github.com/lorenzosax/iot-vibrations-system
cd iot-vibrations-system
# Install dependencies
npm install
If you use Yarn, just replace npm
with yarn
in the commands.
There are two files for configurations, one for production and another for development.
The selection is made by looking at the value of the environment variable NODE_ENV
:
NODE_ENV=production
will be loadedconfig/production.js
fileNODE_ENV=<otherValue>
will be loadedconfig/default.js
file
You can also create a new configuration file (by copying one of those already present) and renaming it as you want, so that the name will correspond to the value of the environment variable NODE_ENV that will be set
This configuration file uses some environment variables which must necessarily be set:
PORT
(default value is80
)DB_USR
DB_PWD
JWT_SECRET_KEY
GMAIL_USR
GMAIL_PWD
The last three environment variables are used because the user registration and login part is also implemented; all this happens thanks to the generation of a JWT that will keep the session open for a certain time configurable. To confirm a new registration, email verification will be required, for this reason it is necessary to enter a gmail account that will send the email.
npm run start:dev
This command starts a nodemon process for your server restart when a code change happens.
npm run start
This command starts the application server with production.js
configurations (if NODE_ENV
is set to production
)
This scaffold uses ESlint. It extends google's eslint config. Feel free to use your own rules or extend any other desirable rule(e.g airbnb) You can run linting in watch mode with:
npm run lint
Note: npm run start:dev
starts the server with linting in watch mode, you can remove it if need be.
This scaffold uses Mocha. It also uses Supertest to demonstrate a simple routing test suite. Feel free to remove the supertest if you don't wish to use it. You can start the test runner in watch mode with:
npm test