• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript angular2-express-engine.createEngine函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap