Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is __meteor_bootstrap__?

Tags:

meteor

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

It is complaining that __meteor_bootstrap__.app is undefined.

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...

like image 292
wciu Avatar asked Aug 16 '13 04:08

wciu


1 Answers

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.

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 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.

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))

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

More about connect: https://npmjs.org/package/connect

like image 73
imslavko Avatar answered Oct 26 '22 06:10

imslavko