text: // REST API for ROS server
  const express = require('express');
  const cors = require('cors');
  const app = express();
  const db = require('./models');
  const corsOptions = { origin: '*' };
  const expressJwt = require('express-jwt');
  
  // JWT options
  app.use(expressJwt({ secret: 'soup-app-secret', algorithms: ['HS256'] }).unless({ path: ['/api/soup/auth'] }));
  app.use((err, _req, res, _next) => {
      if (err.name === 'UnauthorizedError') {
          res.status(401).send({ message: 'Invalid token' });
      }
  });
  
  // Plants DB
  const plants = db.plants;
  
  // CORS policy
  app.use(cors(corsOptions));
  
  // Parse requests of content-type - application/json
  app.use(express.json());
  
  // Parse requests of content-type - application/x-www-form-urlencoded
  app.use(express.urlencoded({ extended: true }));
  
  // Simple route for base URL
  app.get('/', (_req, res) => {
      res.json({ message: 'SOUP REST API is working' });
  });
  
  // Set port, listen for requests
  const PORT = process.env.PORT || 8080;
  app.listen(PORT, () => {
      console.log(`Server is running on port ${PORT}`);
  });
  
  require('./routes/routes')(app);
  //Start listener
  app.listen(8081);
  
  // Check connection and connect
  start();
  async function start() {
      try {
          await db.sequelize.authenticate();
          console.log('Connection has been established successfully');
          // Create new DB if not exist
          await db.sequelize.sync().then(() => {
              // Check plants DB existance
              plants.findAll({}).then(data => {
                  if (data.length === 0 || data.length > 54) {
                      // Insert plants on init
                      let PLANTS = [];
                      for (let i = 0; i < 27; i++) {
                          PLANTS.push(
                              {
                                  name: (i + 1) + 'A',
                                  plantpositionx: 0,
                                  plantpositiony: 0,
                                  plantingdate: null,
                                  planttype: '',
                                  lastgathering: null,
                                  gatheredfruits: 0
                              },
                              {
                                  name: (i + 1) + 'B',
                                  plantpositionx: 0,
                                  plantpositiony: 0,
                                  plantingdate: null,
                                  planttype: '',
                                  lastgathering: null,
                                  gatheredfruits: 0
                              })
                      }
                      plants.bulkCreate(PLANTS).then(() => {
                          console.log('Plants have planted');
                      });
                  }
              }).catch(err => {
                  console.log(err);
              });
          })
      } catch (error) {
          console.error('Unable to connect to the database: ', error);
      }
      // Trigger the inpector every 120 seconds
      setInterval(dbInspector, 120000);
  }
  
  // DB Connection inspector
  async function dbInspector() {
      try {
          await db.sequelize.authenticate();
          console.log('Database is connected');
      } catch (error) {
          console.error('Connection error: ', error);
      }
  }