Skip to content

Instantly share code, notes, and snippets.

@nicolasmendoza
Last active January 9, 2017 18:32
Show Gist options
  • Select an option

  • Save nicolasmendoza/741ff6d7911199d9fd4b473a04661f06 to your computer and use it in GitHub Desktop.

Select an option

Save nicolasmendoza/741ff6d7911199d9fd4b473a04661f06 to your computer and use it in GitHub Desktop.

Revisions

  1. Nicolás revised this gist Jan 9, 2017. No changes.
  2. Nicolás revised this gist Jan 9, 2017. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  3. Nicolás revised this gist Jan 9, 2017. 2 changed files with 45 additions and 0 deletions.
    45 changes: 45 additions & 0 deletions LeviatanWithKeystone.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    var path = require('path'),
    virtualhost = require('express-vhost'),
    express = require('express'),
    server = express();

    var keystone = require('keystone');

    var app2 = require('./app1/index').app;
    /*
    ::app1/index.js (ejemplo)
    var express = require('express');
    var portalRoutes = require('./app1Routes');
    var http = require('http');
    var app1 = express();
    app1.use(app1Routes);
    exports.app = app1;
    */

    // activar vhost expressJS, see: "Expressjs behind proxies" here -https://expressjs.com/en/guide/behind-proxies.html
    server.use(virtualhost.vhost(server.enabled('trust proxy')));
    // puerto escuha de nuestro server. 80 ?
    server.listen(3000);

    //keystone maquinaria
    keystone.init({
    //... [...]
    });
    keystone.import('models');
    keystone.set([...]);
    keystone.app.use([...]);
    [etc...]

    //Importante!! reemplazar keystone.run() por keystone.mount().
    //documentación: https://github.com/keystonejs/keystone/wiki/Keystone-API
    //keystone.run()
    keystone.mount();

    //enjoy the leviatán.
    virtualhost.register('www.asereje.com', keystone.app);
    virtualhost.register('www.learn.asereje.com', app2);

    File renamed without changes.
  4. Nicolás revised this gist Jan 9, 2017. No changes.
  5. Nicolás created this gist Jan 9, 2017.
    30 changes: 30 additions & 0 deletions server.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    var path = require('path'),
    virtualhost = require('express-vhost'),
    express = require('express'),
    server = express();

    var app1 = require('./app1/index').app;
    /*
    ::app1/index.js (ejemplo)
    var express = require('express');
    var portalRoutes = require('./app1Routes');
    var http = require('http');
    var app1 = express();
    app1.use(app1Routes);
    exports.app = app1;
    */
    var app2 = require('./app2/index').app;

    // activar vhost expressJS, see: "Expressjs behind proxies" here -https://expressjs.com/en/guide/behind-proxies.html
    server.use(virtualhost.vhost(server.enabled('trust proxy')));
    // puerto escuha de nuestro server. 80 ?
    server.listen(3000);

    virtualhost.register('www.asereje.com', app1);
    virtualhost.register('www.learn.asereje.com', app2);

    [etc...]