當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular2-express-engine.createEngine函數代碼示例

本文整理匯總了TypeScript中angular2-express-engine.createEngine函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createEngine函數的具體用法?TypeScript createEngine怎麽用?TypeScript createEngine使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createEngine函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createEngine

const engine = (filePath: string, data: ejs.Data, done: Function): Function => {
  const angularEngine = createEngine({});

  return angularEngine(filePath, data, (err, str) => {
    done(err, ejs.render(str, {assetUrl: assetUrl}));
  });
};
開發者ID:threesquared,項目名稱:3sq.re,代碼行數:7,代碼來源:server.ts

示例2: createEngine

   */

  host: process.env.HOST || '0.0.0.0',
  /**
   * The port to bind the web server to
   */
   // We have to Remove this for Webpack Heroku
  // port: process.env.PORT,

  /**
   * Alternate method to add multiple template engine, for single view template use config.views.engine
   */
  views: {
    engines: {
      'ng2.html': createEngine({
        precompile: true,
        ngModule: MainModule
      })
    },
    // engines: {
    //   'ng2.html': 'html'
    // },
    path: require('../treefrog.json').outDir
  }

  /**
   * SSL options
   * Cert and key or pfx to create HTTPS server
   */
  /*
  ssl: {
    key: fs.readFileSync('path/to/private.key'),
開發者ID:Lumenss,項目名稱:testing-app,代碼行數:32,代碼來源:web.ts

示例3: enableProdMode

import * as path from 'path';
import * as express from 'express';

import { enableProdMode } from '@angular/core';
import { createEngine } from 'angular2-express-engine';
// Angular 2 Universal
enableProdMode();

import { main } from './main.node';

const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));

// Express View
app.engine('.html', createEngine({ main, time: true }));
app.set('views', __dirname);
app.set('view engine', 'html');

// Serve static files
app.use(express.static(ROOT, { index: false }));

app.get('/', function (req, res, next) {
  res.render('index', { req, res });
});


// Server
app.listen(3000, () => {
  console.log('Listening on: http://localhost:3000');
});
開發者ID:jeffwhelpley,項目名稱:universal,代碼行數:30,代碼來源:server-express.ts

示例4: ConnectToDatabase

});

/*
 * Connect to database
 * Info: See database.ts to configure settings
 */

 import { ConnectToDatabase } from './database';

 ConnectToDatabase();


/*
 * Configure Express.js rendering engine
 */
app.engine('.html', createEngine({}));
app.set('views', path.join(ROOT, '/public/views'));
app.set('view engine', 'html');

/*
 * Configure Middleware
 */
app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json());
app.use(helmet());

/*
 * Set directories to serve static assets from
 */
app.use(express.static(path.join(ROOT, 'public'), {index: false}));
app.use('/assets/js', express.static(path.join(ROOT, '/dist/client')));
開發者ID:Mandosis,項目名稱:2MEAN,代碼行數:31,代碼來源:server.ts

示例5: enableProdMode

import * as path from 'path';
import * as express from 'express';

import { enableProdMode } from '@angular/core';
import { createEngine } from 'angular2-express-engine';
// Angular 2 Universal
enableProdMode();

import { MainModule } from './main.node';

const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));

// Express View
app.engine('.html', createEngine({ ngModule: MainModule, time: true }));
app.set('views', __dirname);
app.set('view engine', 'html');

// Serve static files
app.use(express.static(ROOT, { index: false }));


app.get('/data.json', function(req: any, res: any) {
  console.log('req.headers.cookie', req.headers.cookie);
  console.log('req.cookies', req.cookies);
  var data = JSON.stringify({ data: true }, null, 2);
  console.log('res', data);
  res.status(200).send(data);
});
開發者ID:jeckhart,項目名稱:universal,代碼行數:29,代碼來源:server-express.ts

示例6: enableProdMode

// Routes
import { routes } from './server.routes';

// enable prod for faster renders
enableProdMode();

const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));

// Express View
app.engine('.html', createEngine({
  ngModule: MainModule,
  providers: [
    // use only if you have shared state between users
    // { provide: 'LRU', useFactory: () => new LRU(10) }

    // stateless providers only since it's shared
  ]
}));
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname);
app.set('view engine', 'html');
app.set('json spaces', 2);

app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json());
app.use(compression());

app.use(morgan('dev'));
開發者ID:pmachowski,項目名稱:angular2-starter-kit,代碼行數:29,代碼來源:server.ts

示例7: enableProdMode

// Routes
import { routes } from './server.routes';

// enable prod for faster renders
enableProdMode();

const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));

// Express View
app.engine('.html', createEngine({
  precompile: false, // this needs to be false when using ngFactory
  ngModule: MainModuleNgFactory,
  providers: [
    // use only if you have shared state between users
    // { provide: 'LRU', useFactory: () => new LRU(10) }

    // stateless providers only since it's shared
  ]
}));
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname);
app.set('view engine', 'html');
app.set('json spaces', 2);

app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json());
app.use(compression());

const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', {flags: 'a'})
開發者ID:kuldeepkeshwar,項目名稱:universal-starter,代碼行數:30,代碼來源:server.aot.ts


注:本文中的angular2-express-engine.createEngine函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。