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

TypeScript express-engine.ngExpressEngine函数代码示例

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

本文整理汇总了TypeScript中@nguniversal/express-engine.ngExpressEngine函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ngExpressEngine函数的具体用法?TypeScript ngExpressEngine怎么用?TypeScript ngExpressEngine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ngExpressEngine函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: ngExpressEngine

const bootstrap = () => {
  app.engine('html', ngExpressEngine({
    bootstrap: AppServerModule
  }));
  app.set('view engine', 'html');
  app.set('views', './');
  app.use('/', express.static('./', { index: false }));
  app.get('*', (req, res) => {
    res.render('index', {
      req,
      res
    });
  });
  app.listen(port, () => {
    console.log(`Listening at ${baseUrl}`);
  });
};
开发者ID:alonn24,项目名称:alonn24.github.io,代码行数:17,代码来源:main.server.ts


示例2: enableProdMode

import { ServerAppModuleNgFactory } from './ngfactory/app/server-app.module.ngfactory';
import { ngExpressEngine } from '@nguniversal/express-engine';
import { ROUTES } from './routes';
import { enableProdMode } from '@angular/core';

enableProdMode();
const app = express();

app.use(compression());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(awsServerlessExpressMiddleware.eventContext());

app.engine('html', ngExpressEngine({
  bootstrap: ServerAppModuleNgFactory
}));

app.set('view engine', 'html');
app.set('views', 'src');

app.use('/', express.static('dist', { index: false }));

ROUTES.forEach((route) => {
  app.get(route, (req, res) => {
    res.render('../dist/index', { req, res });
  });
});

// redirection from safari notification to given external page
app.get('/redirect/**', (req, res) => {
开发者ID:gshiva,项目名称:angular-universal-serverless,代码行数:31,代码来源:main.server.aot.ts


示例3: readFileSync

// Our index.html we'll use as our template
const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main.bundle');

// Express Engine
import { ngExpressEngine } from '@nguniversal/express-engine';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';

// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({
  bootstrap: AppServerModuleNgFactory,
  providers: [
    provideModuleMap(LAZY_MODULE_MAP)
  ]
}));

app.set('view engine', 'html');
app.set('views', join(DIST_FOLDER, 'browser'));

/* - Example Express Rest API endpoints -
  app.get('/api/**', (req, res) => { });
*/

// Server static files from /browser
app.get('*.*', express.static(join(DIST_FOLDER, 'browser'), {
  maxAge: '1y'
}));
开发者ID:MarkPieszak,项目名称:universal-starter,代码行数:30,代码来源:server.ts


示例4: enableProdMode

import { ngExpressEngine, REQUEST } from '@nguniversal/express-engine';
import { enableProdMode } from '@angular/core';
import { USERAGENTTOKEN } from './app/windowRef';

enableProdMode();
export const app = express();

app.use(compression());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(awsServerlessExpressMiddleware.eventContext());

app.engine('html', ngExpressEngine({
  bootstrap: ServerAppModule,
    providers: [
        {provide: USERAGENTTOKEN, useValue: REQUEST }
    ]
}));

app.set('view engine', 'html');
app.set('views', 'dist');

app.use('/', express.static('dist', { index: false }));

app.get('/**', (req, res) => {
    if (req.headers.host.indexOf('angular-universal-pwa.maciejtreder.com') > -1 && req.headers.host !== 'www.angular-universal-pwa.maciejtreder.com') {
        res.writeHead (301, {Location: 'https://www.angular-universal-pwa.maciejtreder.com'});
        res.end();
        return;
    }
    res.render('index', {req, res});
开发者ID:yantrixs,项目名称:angular-universal-pwa,代码行数:32,代码来源:main.server.ts


示例5: require

/* tslint:disable */
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
/* tslint:enable */
import * as express from 'express';
import * as functions from 'firebase-functions';
import * as fs from 'fs';
import { ngExpressEngine } from '@nguniversal/express-engine';
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';

const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./app/main');

const engine = ngExpressEngine({
  bootstrap: AppServerModuleNgFactory,
  providers: [
    provideModuleMap(LAZY_MODULE_MAP)
  ]
});

const document: string = fs.readFileSync(__dirname + '/app/index.html', 'utf8').toString();

const app = express();
app.get('**', (req, res) => {
  const url: string = req.path;
  engine(url, {
    req,
    res,
    url,
    document,
    bootstrap: AppServerModuleNgFactory,
    providers: [
开发者ID:MichaelSolati,项目名称:ng-portfolio,代码行数:31,代码来源:ssr.ts


示例6: enableProdMode

import { enableProdMode } from '@angular/core';

// libs
import * as express from 'express';
import * as compression from 'compression';
import { ngExpressEngine } from '@nguniversal/express-engine';

// module
import { AppServerModule } from './app/app.server.module';

enableProdMode();
const server = express();
server.use(compression());

server.engine('html', ngExpressEngine({
  bootstrap: AppServerModule
}));

server.set('view engine', 'html');
server.set('views', 'public');
server.use('/', express.static('public', {index: false}));

server.get('*', (req, res) => {
  res.render('../public/index.html', {
    req,
    res
  });
});

const PORT = process.env.PORT || 8000;
const HOST = process.env.BASE_URL || 'localhost';
开发者ID:John123Yu,项目名称:universal-1,代码行数:31,代码来源:server.ts



注:本文中的@nguniversal/express-engine.ngExpressEngine函数示例由纯净天空整理自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