本文整理汇总了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
}
});
};
示例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);
});
};
示例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);
});
示例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;
}
示例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
}
});
};
示例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);
};