2017-06-10 14:53:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var config = require('./example-config.json');
|
2017-12-23 21:45:27 +00:00
|
|
|
//var favicon = require('static-favicon');
|
2017-06-10 14:53:29 +00:00
|
|
|
var cookieParser = require('cookie-parser')
|
|
|
|
var path = require('path');
|
|
|
|
var winston = require('winston');
|
|
|
|
winston.loggers.add('main',config.winston);
|
|
|
|
var log = winston.loggers.get('main');
|
|
|
|
var expressWinston = require('express-winston');
|
|
|
|
var tcrud = require('../lib/node-ff-tcrud');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
|
|
|
|
// PHASE_1: load extra plugins
|
|
|
|
//tcrud.setup.pluginLoad(new MyPlugin());
|
|
|
|
require('./lib/pg-moviedb').load(tcrud);
|
|
|
|
require('./lib/pg-pagila').load(tcrud);
|
|
|
|
|
|
|
|
// PHASE_2: enable plugins
|
|
|
|
tcrud.setup.pluginEnableAll();
|
|
|
|
|
|
|
|
// PHASE_3: start config
|
|
|
|
tcrud.setup.phaseConfig();
|
|
|
|
tcrud.config.getRootTEntity().tmeta.tplugin.formatXML.tslug = 'xml_is_free';
|
|
|
|
tcrud.config.getRootTEntity().tmeta.tplugin.formatCSV.tslug = 'csv4all';
|
|
|
|
var tPostgresDB = tcrud.config.createTEntityNode(tcrud.config.getRootTEntity(),'pg');
|
|
|
|
var tMongoose = tcrud.config.createTEntityNode(tcrud.config.getRootTEntity(),'mongoose');
|
|
|
|
require('./lib/pg-moviedb').setup(tcrud,tPostgresDB);
|
|
|
|
require('./lib/pg-pagila').setup(tcrud,tPostgresDB);
|
|
|
|
//require('./lib/mongoose-blog').setup(tcrud,tMongoose);
|
|
|
|
|
|
|
|
// PHASE_4: finalize config
|
|
|
|
tcrud.setup.phaseServer();
|
|
|
|
//tcrud.setup.expressSimple(); or complex;
|
|
|
|
|
|
|
|
var server = tcrud.setup.expressCreate();
|
|
|
|
server.use(expressWinston.logger({
|
|
|
|
transports: [new winston.transports.Console({json: false,colorize: true})],
|
|
|
|
meta: false,
|
|
|
|
expressFormat: true
|
|
|
|
}));
|
|
|
|
|
|
|
|
var buildOptions = {
|
|
|
|
viewsDir: path.join(__dirname, 'www_views')
|
|
|
|
}
|
|
|
|
tcrud.setup.expressBuild(buildOptions);
|
|
|
|
|
2017-12-23 21:45:27 +00:00
|
|
|
//server.use(favicon());
|
2017-06-10 14:53:29 +00:00
|
|
|
server.use(cookieParser(config.options.cookieParser.secretKey));
|
|
|
|
|
|
|
|
//server.get('/ui/thtml/*', tcrud.setup.express.renderTemplatePath('thtml/'));
|
|
|
|
|
|
|
|
server.use(expressWinston.errorLogger({
|
|
|
|
transports: [new winston.transports.Console({json: false,colorize: true})]
|
|
|
|
}));
|
|
|
|
|
|
|
|
tcrud.setup.expressListen();
|
|
|
|
|
|
|
|
//PHASE_6: post boot to from self.
|
|
|
|
tcrud.setup.phaseServerUp();
|