Skip to content
Snippets Groups Projects
Select Git revision
  • bc85d51832eddc3e12301631855c3db2f3e1cf77
  • master default protected
  • 3-regression-l-onglet-network-reste-vide
  • v1.7.5 protected
  • v1.7.4 protected
  • v1.7.3 protected
  • v1.7.2 protected
  • v1.7.1 protected
  • v1.7.0 protected
  • v1.6.31 protected
  • v1.6.30 protected
  • v1.6.29 protected
  • v1.6.28 protected
  • v1.6.27 protected
  • v1.6.26 protected
  • v1.6.25 protected
  • v1.6.24 protected
  • v1.6.23 protected
  • v1.6.22 protected
  • v1.6.21 protected
  • v1.6.20 protected
  • v1.6.19 protected
  • v1.6.18 protected
23 results

index.js

Blame
  • index.js 1.70 KiB
    "use strict";
    
    const co = require('co');
    const bodyParser = require('body-parser');
    const http    = require('http');
    const express = require('express');
    const path    = require('path');
    const webminController = require('./server/controller/webmin.js');
    
    // Inject 'webstart' command if no argument was given
    if (process.argv.length === 2) {
      process.argv.push('webstart');
    }
    
    module.exports = {
      duniter: {
    
        'cli': [{
          name: 'webstart',
          desc: 'Do a webstart',
          requires: ['service'],
          promiseCallback: (duniterServer) => co(function*(){
    
            try {
    
              /****************************************
               * SPECIALISATION
               ***************************************/
    
              const app = express();
              const HOTE = 'localhost';
              const PORT = 9220;
    
              /**
               * Sur appel de l'URL /abc
               */
              app.use(express.static(path.join(__dirname, '..', 'duniter-ui', 'public')));
    
              app.use(bodyParser.urlencoded({
                extended: true
              }));
              app.use(bodyParser.json());
    
              const wbmin = webminController(duniterServer);
              const httpServer = http.createServer(app);
              httpServer.listen(PORT, HOTE);
              console.log("Serveur web disponible a l'adresse http://%s:%s", HOTE, PORT);
    
              require('./server/lib/routes').webmin(wbmin, app);
              require('./server/lib/routes').webminWS(wbmin)(httpServer);
    
              yield wbmin.startHTTP();
    
              // Never ending promise
              return new Promise((resolve) => {});
    
              /****************************************/
    
            } catch (e) {
              console.error(e);
              process.exit(1);
            }
          })
        }]
      }
    };