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


TypeScript proxy-middleware.default函數代碼示例

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


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

示例1: browserSync

let runServer = () => {
  let baseDir = APP_DEST;
  let routes:any = {
    [`${APP_BASE}${APP_DEST}`]: APP_DEST,
    [`${APP_BASE}node_modules`]: 'node_modules',
  };

  if (APP_BASE !== '/') {
    routes[`${APP_BASE}`] = APP_DEST;
    baseDir = `${DIST_DIR}/empty/`;
  }

  browserSync({
    port: PORT,
    startPath: APP_BASE,
    server: {
      baseDir: baseDir,
      middleware: [
        proxy({
          protocol: 'http:',
          hostname: 'localhost',
          port: 3000,
          pathname: '/api',
          route: '/api'
        }),
        require('connect-history-api-fallback')({index: `${APP_BASE}index.html`})
      ],
      routes: routes
    }
  });
};
開發者ID:victir,項目名稱:todo-angular2-rails-api,代碼行數:31,代碼來源:code_change_tools.ts

示例2: WebpackDevServer

module.exports=(app)=>{
    app.use("/static",proxy(url.parse(hotReloadServerUri + '/static')));
    var bundleStart = null;
    var compiler = webpack(config);

    // We give notice in the terminal when it starts bundling and
    // set the time it started
    compiler.plugin('compile', ():void=> {
        console.log('Bundling...');
        bundleStart = Date.now();
    });

    // We also give notice when it is done compiling, including the
    // time it took. Nice to have
    compiler.plugin('done', ():void=> {
        console.log('Bundled in ' + (Date.now() - bundleStart) + 'ms. ' + new Date().toString());
    });

    new WebpackDevServer(compiler, {
        //contentBase: hotReloadServerUri || __dirname,
        contentBase: "client",
        hot: true,
        noInfo: true,
        publicPath: '/static/',
        historyApiFallback: false,
        stats: {colors: true},
       // proxy: {
       //     "*": serverUri
       // }
    }).listen(hotReloadServerPort, hotReloadServerHost, ()=> {
        console.log('Bundling project, please wait...'+hotReloadServerPort);
    });
};
開發者ID:duanguang,項目名稱:react-redux-demo,代碼行數:33,代碼來源:webpack-dev-server.ts

示例3: browserSync

gulp.task('serve:prod', ['build:prod'], () => {
    // Proxy to localhost:8080
    var proxyOptions = url.parse('http://localhost:8080/api');
    proxyOptions.route = '/api';
    proxyOptions.preserveHost = true;

    browserSync({
        logPrefix: 'VASS Angular2 Test',
        port: 5000,
        browser: 'google chrome',
        server: {
            baseDir: './dist',
            middleware: [function (req, res, next) {
                // CORS Origin....
                    res.setHeader('Access-Control-Allow-Origin', '*');
                    next();
                }, proxy(proxyOptions)]
        }
    });

    // Watch for changes on build folder. A change on src folder will make watch task run.
    // This task will put the files on build folder.
    // So, we ahve to watch on build folder to reload the browser 
    gulp.watch([
        "/build/**/*.js",
        "/build/**/*.css",
        "/build/**/*.html"
    ], browserSync.reload);
});
開發者ID:nestis,項目名稱:widgetFrontAngular2,代碼行數:29,代碼來源:gulpfile.ts

示例4: setupMiddleware

    public setupMiddleware(): server {
      const proxyOptions: ProxyOption = url.parse( 'http://' + this.option.remoteAddr );
      proxyOptions.preserveHost = true;
      proxyOptions.headers = {host: this.option.host};
      this.app.use((req:http.IncomingMessage,res:http.ServerResponse,next:Function)=>{
        this.option.logger.request(req,res);
        next();
      } );

      this.app.use( '/api/recotw', proxy( proxyOptions ) );
      this.app.use( serveStatic( this.option.root ) );
      return this;
    }
開發者ID:RecoTwExplorer,項目名稱:recotw-proxy,代碼行數:13,代碼來源:server.ts

示例5: browserSync

let runServer = () => {
  //browserSync.init(BROWSER_SYNC_CONFIG);
  let baseDir = APP_DEST;
  let routes: any = {
    [`${APP_BASE}${APP_DEST}`]: APP_DEST,
    [`${APP_BASE}node_modules`]: 'node_modules',
  };

  if (APP_BASE !== '/') {
    routes[`${APP_BASE}`] = APP_DEST;
    baseDir = `${DIST_DIR}/empty/`;
  }

  browserSync({
    port: PORT,
    startPath: APP_BASE,
    server: {
      baseDir: baseDir,
      middleware: [
        /* Connect to localhost backend server. */
        proxy({
          protocol: 'http:',
          hostname: 'localhost',
          port: 3000,
          pathname: '/api',
          route: '/api'
        }),

        /* Connect to Heroku backend server. */
        // proxy({
        //   protocol: 'https:',
        //   hostname: 'powerful-lowlands-67740.herokuapp.com',
        //   //port: ,
        //   pathname: '/api',
        //   route: '/api'
        // }),


        require('connect-history-api-fallback')({ index: `${APP_BASE}index.html` })
      ],
      routes: routes
    }
  });
};
開發者ID:shaggyshelar,項目名稱:angular2-seed,代碼行數:44,代碼來源:code_change_tools.ts

示例6: function

module.exports = function (app: any, passport: any) {
    var router = express.Router();
    post(router, passport);
    pages(router);
    if (process.env.NODE_ENV === 'development') {
        let base = path.join(__dirname, "..", "..", "assets");
        console.log("Base : " + base);
        //console.log(__dirname);
        let server = new WebpackDevServer(webpack(config), {
            contentBase: base,
            hot: true,
            quiet: false,
            noInfo: false,
            publicPath: "/bundle/",
    
            stats: { colors: true }
        });
        server.listen(8081, "localhost", function () { });
        app.use('/bundle', proxy(url.parse('http://localhost:8081/bundle')));
    }
    app.use('/', router);
};
開發者ID:mortonprod,項目名稱:CleaningWebsite,代碼行數:22,代碼來源:index.ts


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