main.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env node
  2. // Gestion des commandes et des options de l'application
  3. const argv = require('yargs')
  4. .command('serve [port]', 'start the Loquicompta server', (yargs) => {
  5. yargs.positional('port', {describe: 'port to bind', default: 80});
  6. }, (argv) => {})
  7. .command('dev', 'start the Loquicompta server on 8080 port with verbose', (yargs) => {}, (argv) => {
  8. argv.port = 8080;
  9. argv.verbose = 1;
  10. })
  11. .option('port', {
  12. alias: 'p',
  13. default: 80
  14. })
  15. .option('auth', {
  16. default: true
  17. })
  18. .count('verbose')
  19. .alias('v', 'verbose')
  20. .describe('p', 'port to bind')
  21. .describe('v', 'show all informations')
  22. .describe('auth', 'disables authentication')
  23. .argv;
  24. // Bibliotheques
  25. const express = require('express');
  26. // Creation variable globale
  27. global.app = express();
  28. global.verbose = argv.verbose >= 1;
  29. global.auth = argv.auth;
  30. // Configuration server
  31. require('./src/route');
  32. // Lancement serveur
  33. app.listen(argv.port, () => {
  34. console.info(`Server starting on port ${argv.port} (http://localhost:${argv.port})`);
  35. });