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

TypeScript connect-history-api-fallback.default函数代码示例

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

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



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

示例1: function

module.exports = function(ROOT) {
  var router = Router();

  var appPage = require('../../universal/test_page/app');
  var todoApp = require('../../universal/todo/app');
  var routerApp = require('../../universal/test_router/app');

  var {enableProdMode, provide} = require('angular2/core');
  var {ROUTER_PROVIDERS, APP_BASE_HREF} = require('angular2/router');

  enableProdMode();

  var {
    NODE_ROUTER_PROVIDERS,
    NODE_HTTP_PROVIDERS,
    NODE_PLATFORM_PIPES,
    REQUEST_URL,
    BASE_URL,
    queryParamsToBoolean
  } = require('angular2-universal');

  router
    .route('/')
    .get(function ngApp(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams, {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/src/universal/test_page/browser',

        // directives: [appPage.App],
        directives: [appPage.App, appPage.MyApp],
        providers: [
          provide(REQUEST_URL, {useValue: req.originalUrl}),
          provide(APP_BASE_HREF, {useValue: '/'}),
          provide(BASE_URL, {useExisting: req.originalUrl}),

          NODE_PLATFORM_PIPES,
          NODE_ROUTER_PROVIDERS,
          NODE_HTTP_PROVIDERS,
        ],
        data: {},

        async: true,

        systemjs: {
          componentUrl: 'examples/src/universal/test_page/browser',
          map: {
            'angular2-universal': 'node_modules/angular2-universal'
          },
          packages: {
            'angular2-universal/polyfills': {
              format: 'cjs',
              main: 'dist/polyfills',
              defaultExtension: 'js'
            },
            'angular2-universal': {
              format: 'cjs',
              main: 'dist/browser/index',
              defaultExtension: 'js'
            }
          }
        },

        preboot: queryParams.preboot === false ? null : {
          appRoot: 'app', // we need to manually include the root

          start:    true,
          freeze:   'spinner',     // show spinner w button click & freeze page
          replay:   'rerender',    // rerender replay strategy
          buffer:   true,          // client app will write to hidden div until bootstrap complete
          debug:    false,
          uglify:   true,
          presets:  ['keyPress', 'buttonPress', 'focus']
        },
        ngOnRendered: () => {
          console.log('DONE');
        }

      });

      res.render('src/universal/test_page/index', options);

    });

  router
    .route('/examples/todo')
    .get(function ngTodo(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams , {
        // client url for systemjs
        buildClientScripts: true,
        systemjs: {
          componentUrl: 'examples/src/universal/todo/browser',
          map: {
            'angular2-universal': 'node_modules/angular2-universal'
          },
          packages: {
            'angular2-universal/polyfills': {
              format: 'cjs',
//.........这里部分代码省略.........
开发者ID:ultrasonicsoft,项目名称:universal,代码行数:101,代码来源:routes.ts


示例2: express

> = (context: interfaces.Context) => (app?: express.Application) => {
  if (!app) {
    app = express();
  }
  context.container.get<interfaces.Factory<express.Application>>(
    registry.ExpressConfig
  )(app);
  useContainer(context.container);
  useExpressServer(app, {
    routePrefix: '/api',
    controllers: [
      CardSetController
    ],
    development: true,
    validation: { validationError: { target: false, value: false } }
  });
  app.use(historyApiFallback());
  app.use(
    webpackMiddleware(webpack(webpackDevConfig), {
      publicPath: '/',
      index: 'index.html',
      stats: {
        colors: true
      }
    })
  );
  context.container.get<interfaces.Factory<express.Application>>(
    registry.ExpressErrorConfig
  )(app);

  return app;
};
开发者ID:patrickhousley,项目名称:xyzzy-mean,代码行数:32,代码来源:express-dev.ts


示例3: convert

 add: (app: any) => {
   app.use(
     convert(
       history({
         rewrites: [{ from: /\.html$/, to: '/' }],
       })
     )
   )
 },
开发者ID:leslieSie,项目名称:docz,代码行数:9,代码来源:devserver.ts


示例4: getBrowserReleaseConfig

export const getWebpackConfig = (opts: Options = {}): Configuration => {
  if (typeof opts === 'string') {
    throw `Expected an options object, but got the string "${opts}"`;
  }

  const { type = project.ws.type, env = {} } = opts;

  // convert new env map to old env key-value-array
  const oldEnv = Object.entries(env).map(([key, value]) => ({
    key,
    value
  }));
  const options = {
    parent: {
      env: oldEnv
    }
  };

  switch (type) {
    case 'browser':
      return getBrowserReleaseConfig(options);
    case 'node':
      return getNodeBuildConfig(options);
    case 'cypress':
      return getSpaE2eConfig(options);
    case 'spa':
      if (process.env.WEBPACK_DEV_SERVER) {
        const config = getSpaBuildConfig(options);
        const publicPath = project.ws.publicPath ? project.ws.publicPath : '/';
        config.devServer = {
          stats: 'errors-only',
          publicPath,
          hot: true,
          before(app) {
            app.use((req, res, next) => {
              if (publicPath !== '/' && req.path === '/') {
                res.redirect(publicPath);
              } else {
                next();
              }
            });
            app.use(
              history({
                index: join(publicPath, '/index.html')
              })
            );
          }
        };
        return config;
      } else {
        return getSpaReleaseConfig(options);
      }
  }
};
开发者ID:Mercateo,项目名称:ws,代码行数:54,代码来源:webpack.ts


示例5: fallback

gulp.task('start:server', () => {
  browserSync.init({
    server: {
      baseDir: './build/',
      https: false,
      open: false,
      middleware: [
        fallback({
          index: '/index.html',
          htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'] // systemjs workaround
        })
      ]
    }
  });
});
开发者ID:andreasonny83,项目名称:angular2-starter-kit,代码行数:15,代码来源:gulpfile.ts


示例6: registerCompiler

const createBrowserSyncOptions = (options: IOptions): browserSync.Options => {
  const webpackConfigFile = path.join(process.cwd(), options.config);
  const webpackConfigFileExt = path.extname(webpackConfigFile);

  registerCompiler(interpret.extensions[webpackConfigFileExt] as any);

  const webpackConfig = require(webpackConfigFile);

  let middlewares: browserSync.MiddlewareHandler[] = [];

  if (options.historyApiFallback) {
    middlewares = middlewares.concat(connectHistoryApiFallback({
      index: "/"
    }) as any);
  }

  if (options.webpack) {
    middlewares = middlewares.concat(createMiddlewaresForWebpack(webpackConfig, options.index, options.hot) as any);
  }

  if (options.compress) {
    middlewares = middlewares.concat(compress({ level: 6 }) as browserSync.MiddlewareHandler);
  }

  if (options.proxy) {
    return {
      ...(get(webpackConfig, "devServer.browserSync")),
      proxy: {
        target: options.proxy as string,
        middleware: middlewares as browserSync.MiddlewareHandler[]
      } as any
    };
  }

  return {
    ...(get(webpackConfig, "devServer.browserSync")),
    ...(process.env.PORT ? ({
      port: Number(process.env.PORT)
    }) : {}),
    server: {
      baseDir: getBaseDir(webpackConfig.output.path, webpackConfig.output.publicPath),
      index: path.join(webpackConfig.output.publicPath || "/", options.index),
      middleware: middlewares as browserSync.MiddlewareHandler[],
    },
    notify: false
  };
};
开发者ID:morlay,项目名称:webpack-browser-sync,代码行数:47,代码来源:index.ts


示例7:

      add    : (app, middleware) => {
        app.use(c2k(proxy(
          config.apiPrefixes,
          {
            target: `http://localhost:${config.serverPort + 1}`,
            secure: false,
          },
        ) as NextHandleFunction))

        app.use(c2k(history({
          index  : `${config.serverIndex}`,
          verbose: false,
        }) as NextHandleFunction))

        middleware.webpack()
        // middleware.content()
      },
开发者ID:whitetrefoil,项目名称:flickr-simple-reorder,代码行数:17,代码来源:dev-server.ts


示例8: ngRouter

module.exports = function(ROOT) {
  var router = Router();

  router
    .route('/')
    .get(function ngApp(req, res) {
      let queryParams: any = queryParamsToBoolean(req.query);
      let options: BootloaderConfig = Object.assign(queryParams, {
        // client url for systemjs
        buildClientScripts: true,

        // directives: [appPage.App],
        directives: [appPage.App, appPage.MyApp],
        platformProviders: [
          provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
          provide(BASE_URL, {useValue: '/'}),
        ],
        providers: [
          provide(REQUEST_URL, {useValue: req.originalUrl}),

          ...NODE_PLATFORM_PIPES,
          ...NODE_ROUTER_PROVIDERS,
          ...NODE_HTTP_PROVIDERS,
        ],
        data: {},

        systemjs: {
          componentUrl: 'examples/src/universal/test_page/browser',
          map: {
            'angular2-universal': 'node_modules/angular2-universal',
            '@angular': 'node_modules/@angular'
          },
          packages: PACKAGES,
        },

        async: queryParams.async === false ? false : true,
        beautify: queryParams.beautify === false ? false : true,

        preboot: queryParams.preboot === false ? null : {
          appRoot: 'app', // we need to manually include the root

          start:    true,
          freeze:   'spinner',     // show spinner w button click & freeze page
          replay:   'rerender',    // rerender replay strategy
          buffer:   true,          // client app will write to hidden div until bootstrap complete
          debug:    false,
          uglify:   true,
          presets:  ['keyPress', 'buttonPress', 'focus']
        },
        ngOnRendered: () => {
          console.log('DONE\n');
        },
        ngDoCheck: () => {
          // return true;
        }

      });

      res.render('src/universal/test_page/index', options);

    });

  router
    .route('/examples/todo')
    .get(function ngTodo(req, res) {
      let queryParams: any = queryParamsToBoolean(req.query);
      let options: BootloaderConfig = Object.assign(queryParams , {
        // client url for systemjs
        buildClientScripts: true,
        systemjs: {
          componentUrl: 'examples/src/universal/todo/browser',
          map: {
            'angular2-universal': 'node_modules/angular2-universal',
            '@angular': 'node_modules/@angular'
          },
          packages: PACKAGES
        },
        directives: [todoApp.TodoApp],
        platformProviders: [
          provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
          provide(BASE_URL, {useValue: '/examples/todo'}),
        ],
        providers: [
          provide(REQUEST_URL, {useValue: req.originalUrl}),
          ...NODE_HTTP_PROVIDERS,
          ...NODE_ROUTER_PROVIDERS,
        ],
        data: {},
        async: queryParams.async === false ? false : true,
        preboot: queryParams.preboot === false ? null : {debug: true, uglify: false}

      });

      res.render('src/universal/todo/index', options);

    });

    router
      .route('/examples/template_url')
      .get(function ngTemplateUrl(req, res) {
//.........这里部分代码省略.........
开发者ID:BizagiStudio,项目名称:universal,代码行数:101,代码来源:routes.ts


示例9: ngRouter

module.exports = function(ROOT) {
  var router = Router();

  var universalPath = `${ROOT}/dist/examples/app/universal`;

  var appPage = require(`${universalPath}/test_page/app`);
  var todoApp = require(`${universalPath}/todo/app`);
  var routerApp = require(`${universalPath}/test_router/app`);

  var {enableProdMode, provide} = require('angular2/core');
  var {ROUTER_PROVIDERS, APP_BASE_HREF} = require('angular2/router');

  enableProdMode();

  var {
    NODE_HTTP_PROVIDERS,
    NODE_LOCATION_PROVIDERS,
    REQUEST_URL,
    PRIME_CACHE,
    queryParamsToBoolean
  } = require('angular2-universal-preview');
  // require('angular2-universal')

  router
    .route('/')
    .get(function ngApp(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams, {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/app/universal/test_page/browser',

        directives: [appPage.App, appPage.MyApp],
        providers: [
          // NODE_HTTP_PROVIDERS,
          // NODE_LOCATION_PROVIDERS,
          // provide(BASE_URL, {useExisting: req.originalUrl}),
          // provide(PRIME_CACHE, {useExisting: true})
        ],
        data: {},

        preboot: queryParams.preboot === false ? null : {
          start:    true,
          freeze:   'spinner',     // show spinner w button click & freeze page
          replay:   'rerender',    // rerender replay strategy
          buffer:   true,          // client app will write to hidden div until bootstrap complete
          debug:    false,
          uglify:   true,
          presets:  ['keyPress', 'buttonPress', 'focus']
        }

      });

      res.render('app/universal/test_page/index', options);

    });

  router
    .route('/examples/todo')
    .get(function ngTodo(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams , {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/app/universal/todo/browser',

        directives: [todoApp.TodoApp],
        providers: [
          // NODE_HTTP_PROVIDERS,
          // NODE_LOCATION_PROVIDERS,
          // provide(BASE_URL, {useExisting: req.originalUrl}),
          // provide(PRIME_CACHE, {useExisting: true})
        ],
        data: {},

        preboot: queryParams.preboot === false ? null : true

      });

      res.render('app/universal/todo/index', options);

    });

  router
    .route('/examples/falcor_todo')
    .get(function ngTodo(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams , {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/app/universal/falcor_todo/client',

        directives: [todoApp.TodoApp],
        providers: [
          // NODE_HTTP_PROVIDERS,
          // NODE_LOCATION_PROVIDERS,
          // provide(REQUEST_URL, {useExisting: req.originalUrl}),
          // provide(PRIME_CACHE, {useExisting: true})
        ],
        data: {},
//.........这里部分代码省略.........
开发者ID:acinader,项目名称:universal,代码行数:101,代码来源:routes.ts


示例10: debug

import history from 'connect-history-api-fallback';

import { CONFIG } from '@eng/config';

const logger = debug('eng:prod:server');

const app = express();

const apiProxy = httpProxy({
    target: CONFIG.API_TARGET,
    changeOrigin: true,
    pathRewrite: { [`^${CONFIG.API_PREFIX}`]: '' },
    secure: false,
});

app.set('port', process.env.PORT || 5000);

app.use(history());

app.use(serveStatic('dist'));

app.use(`${CONFIG.API_PREFIX}/**`, apiProxy);

app.listen(app.get('port'), (err: any) => {
    if (err) {
        logger(err);
    }

    logger(`Serving on port ${app.get('port')}...`);
});
开发者ID:athrunsun,项目名称:oh-my-stars,代码行数:30,代码来源:serve.ts



注:本文中的connect-history-api-fallback.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lib.lib函数代码示例发布时间:2022-05-25
下一篇:
TypeScript connect-flash.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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