__meteor_bootstrap__ 是什么? [英] What is __meteor_bootstrap__?

查看:38
本文介绍了__meteor_bootstrap__ 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Meteor 并致力于一个现有项目.我遇到了一个包含以下行的软件包(observatory-apollo)的问题:

I am just starting with Meteor and working on an existing project. I am running into an issue with one of the packages(observatory-apollo) that's has the following line:

      __meteor_bootstrap__.app.use Observatory.logger #TLog.useragent

抱怨 __meteor_bootstrap__.app 未定义.

__meteor_boostrap__ 究竟是什么?我似乎无法找到它是什么的描述,但是从线程中,人们似乎知道如何使用它.我只能看到它在 boot.js 中定义,但它并没有真正告诉我太多......

What is __meteor_boostrap__ exactly? I can't seem to find a description of what it is but from threads, people seem to know how to use it. I can only see it defined in boot.js, but it doesn't really tell me much...

推荐答案

Meteor 出于各种原因在幕后使用 connect npm 模块,例如为静态文件提供服务.__meteor_bootstrap__.app 是对 connect 应用实例的引用.

Meteor uses connect npm module under the hood for various reasons, to serve static files, for example. __meteor_bootstrap__.app was the reference to connect app instance.

在它之前是 __meteor_bootstrap__.app 但它在几个版本之前更改并成为 WebApp.connectHandlers 对象并且是 WebApp 包的一部分.

Before it was __meteor_bootstrap__.app but it changed couple of releases ago and became WebApp.connectHandlers object and is part of WebApp package.

WebApp 是 Meteor 的标准包,构建 webapp 的核心包.您通常不需要显式添加,因为它是 standard-app-packages 的依赖项.

WebApp is a standard package of Meteor, core package for building webapps. You don't usually need to add explicitly as it is a dependency of standard-app-packages.

connectHandlers 的使用示例是以与使用任何 connect 中间件(或某些 express 中间件)相同的方式注入连接中间件, express 建立在 connect 之上):

Example of usage the connectHandlers is to inject connect middlewares in the same way as you would use any connect middleware (or some express middlewares, express is built on top of connect):

WebApp.connectHandlers
    .use(connect.query())
    .use(this._config.requestParser(bodyParser))

可以查看meteor-router Atmosphere 包,以它为例:https://github.com/tmeasday/meteor-router/blob/master/lib/router_server.js

You can look at meteor-router Atmosphere package and take it as an example: https://github.com/tmeasday/meteor-router/blob/master/lib/router_server.js

更多关于connect:https://npmjs.org/package/connect

这篇关于__meteor_bootstrap__ 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆