Location Framework configurations in File System

Location : ./config

config/
├── certificates
│   ├── ca
│   ├── ca_intermediate
│   ├── client
│   └── server
├── config.js
├── generatedConfig.yml
├── openssl
│   ├── ca
│   └── ca_intermediate
└── pm2.config.js

        

Goblal Configuration File

KERNEL Configuration

You can find the nodefony KERNEL configuration file
This config file do multiple tasks as :

  • Configuring http(s) websoket(s) web servers to start them, listen domain and port, certificats
  • Domain Alias, Domain check
  • Register Bundles (Local and Core)
  • Locale (Lang) by default for all framework
  • Default node package Manager (yarn, npm)
  • ORM to use (Sequelize, Mongoose)
Location : ./config/config.js

/**
 *  NODEFONY FRAMEWORK
 *
 *       KERNEL CONFIG
 *
 *   Domain listen : Nodefony can listen only one domain ( no vhost )
 *     Example :
 *      domain :  0.0.0.0      // for all interfaces
 *      domain :  [::1]        // for IPV6 only
 *      domain :  192.168.1.1  // IPV4
 *      domain :  mydomain.com // DNS
 *
 *   Domain Alias : string only "<>" use domainCheck : true
 *     Example :
 *      domainAlias:[
 *        "^127.0.0.1$",
 *        "^localhost$",
 *        ".*\\.nodefony-starter\\.com",
 *        "^nodefony-starter\\.eu$",
 *        "^.*\\.nodefony-starter\\.eu$"
 *      ]
 */
const path = require("path");

module.exports = {
  system: {
    domain: "0.0.0.0",
    domainAlias: [
      "^127.0.0.1$",
      "^localhost$"
    ],
    httpPort: 5151,
    httpsPort: 5152,
    domainCheck: false,
    locale: "en_en",

    /**
     * BUNDLES CORE
     */
    security: true,
    realtime: true,
    monitoring: true,
    mail: true,
    documentation: false,
    unitTest: true,
    redis: false,
    mongo: false,
    elastic: false,

    /**
     * SERVERS
     */
    servers: {
      statics: true,
      protocol: "2.0", //  2.0 || 1.1
      http: true,
      https: true,
      ws: true,
      wss: true,
      certificats: {
        key: path.resolve("config", "certificates", "server", "privkey.pem"),
        cert: path.resolve("config", "certificates", "server", "fullchain.pem"),
        ca: path.resolve("config", "certificates", "ca", "nodefony-starter-root-ca.crt.pem"),
        options: {
          rejectUnauthorized: true
        }
      }
    },

    /**
     * DEV SERVER
     */
    devServer: {
      inline: true,
      hot: false,
      hotOnly: false,
      overlay: true,
      logLevel: "info", // none, error, warning or info
      progress: false,
      protocol: "https",
      websocket: true
    },

    /**
     *  BUNDLES LOCAL REGISTRATION
     *
     *       bundles:
     *         hello-bundle                 : "file:src/bundles/hello-bundle"
     *         my-bundle                    : require("my-bundle")
     */
    bundles: {},

    /**
     * SYSLOG NODEFONY
     */
    log: {
      active: true
    }
  },

  /**
   *       ASSETS CDN
   *
   *       You set cdn with string
   *       CDN :    "cdn.nodefony-starter.com",
   *       or
   *       CDN:
   *          global: "cdn.nodefony-starter.com",
   *       or
   *       CDN:{
   *         stylesheet:[
   *           "cdn.nodefony-starter.com"
   *         ],
   *         javascript:[
   *           "cdn.nodefony-starter.com"
   *         ],
   *         image:[
   *           "cdn.nodefony-starter.com",
   *           "cdn.nodefony-starter.fr"
   *         ],
   *         font:[
   *           "cdn.nodefony-starter.com"
   *         ]
   *      },
   */
  CDN: null,

  /**
   *  ENGINE TEMPLATE
   *
   *       TWIG
   *       https://github.com/justjohn/twig.js
   *
   */
  templating: "twig",

  /**
   * ENGINE ORM
   *       sequelize || mongoose
   *   orm : mongoose
   */
  orm: "sequelize",

  /**
   * NODE.JS PACKAGE MANAGER
   *
   *       npm
   *       yarn
   */
  packageManager: "npm"

};
	                
Parameters Description Data Type Example / Default
name Name Project String NODEFONY
version Version Framework String Alpha
system.domain

Domain or IP to listen servers HTTP / HTTPS / WEBSOCKET / WEBSOCKET SECURE nodefony can listen only one domain

String localhost or 192.168.0.230 or domain.com 0.0.0.0
system.domainAlias Alias of domain String or array the separator is space for string type regexp only ".*\\.nodefony.com ^nodefony.eu$ ^.*\\.nodefony.eu$"
system.httpPort Port to listen servers HTTP / WEBSOCKET String 5151
system.httpsPort Port to listen servers HTTPS / WEBSOCKET SECURE String 5152
system.servers.http Start http server Boolean true
system.servers.https Start https server Boolean true
system.servers.ws Start websocket server Boolean true
system.servers.wss Start websocket secure server Boolean true
system.servers.certificats Manage certificats for https and websocket secure server tls.connect(options) Object
system.statics If active nodefony can Serve statics files : configurations of service in Application config file For developement use in production use varnish or similar reverse proxy caches in front to serve statics files Boolean true
system.security Auto registre Firewall Bundle Boolean true
system.realtime Auto registre realtime Bundle Boolean true
system.monitoring Auto registre monitoring Bundle (debugBar ... ) Boolean true
locale I18n lang Framework String en_en
CDN Manages CDN for all differents assets. Can be use in twig templates with built-in {{ CDN() }} Object
log.avtive Active syslog in kernel (show log in terminal ) Boolean true
templating Template Engine ( only twig for the moment) String twig
orm ORM Engine ( Sequelize, Mongoose ) String sequelize

Certificates SSL HTTPS Directory ./config/certificates

 ./config/certificates/

  ├── ca
  │   ├── certs
  │   ├── crl
  │   ├── db
  │   ├── newcerts
  │   ├── nodefony-starter-root-ca.crt.pem
  │   ├── nodefony-starter-root-ca.key.pem
  │   ├── private
  │   └── public
  ├── ca_intermediate
  │   ├── certs
  │   ├── crl
  │   ├── csr
  │   ├── db
  │   ├── newcerts
  │   └── private
  ├── client
  │   ├── chain.pem
  │   └── pubkey.pem
  └── server
      ├── cert.pem
      ├── chain.pem
      ├── fullchain.pem
      ├── haproxy.pem
      └── privkey.pem
            

You can manage your https certificates in this directory

Configuration PM2 File ./config/pm2.config.js

Configuration nodefony running mode : PM2 (Production process manager for Node.js )
This Configuration PM2 use by executable nodefony prod

const cpu = require('os').cpus().length;
const path = require("path");

const package = require(path.resolve("package.json"));
const name = package.name;
const script = process.argv[1] || "nodefony";
const logName = `${name}.log`;
const logFile = path.resolve("tmp", logName);

/**
 * Application configuration section
 * http://pm2.keymetrics.io/docs/usage/application-declaration/
 */
module.exports = {
  apps: [{
    name: name,
    script: script,
    args: "pm2",
    //node_args           : "--expose-gc",
    watch: false,
    exec_mode: "cluster",
    instances: cpu,
    max_memory_restart: "1024M",
    autorestart: true,
    max_restarts: 10,
    //log_file            : logFile,
    out_file: logFile,
    error_file: logFile,
    merge_logs: true,
    env: {
      "NODE_ENV": "development",
      "MODE_START": "PM2",
      "NODEFONY_DEBUG": true
    },
    env_production: {
      "NODE_ENV": "production",
      "MODE_START": "PM2",
      "NODEFONY_DEBUG": false
    }
  }]
};
	            
Documentation pm2.keymetrics.io