本文整理匯總了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);
};