mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
webapp and routepolicy need no longer be weak deps
This commit is contained in:
@@ -20,11 +20,7 @@ Package.onUse(function (api) {
|
||||
api.use('ddp-client', 'server');
|
||||
api.imply('ddp-client');
|
||||
|
||||
// It is OK to use this package on a server architecture without making a
|
||||
// server (in order to do server-to-server DDP as a client). So these are only
|
||||
// included as weak dependencies.
|
||||
// XXX split this package into multiple packages or multiple slices instead
|
||||
api.use(['webapp', 'routepolicy'], 'server', {weak: true});
|
||||
api.use(['webapp', 'routepolicy'], 'server');
|
||||
|
||||
// Detect whether or not the user wants us to audit argument checks.
|
||||
api.use(['audit-argument-checks'], 'server', {weak: true});
|
||||
|
||||
@@ -1,47 +1,21 @@
|
||||
// Only create a server if we are in an environment with a HTTP server
|
||||
// (as opposed to, eg, a command-line tool).
|
||||
//
|
||||
// Note: this whole conditional is a total hack to get around the fact that this
|
||||
// package logically should be split into a ddp-client and ddp-server package;
|
||||
// see https://github.com/meteor/meteor/issues/3452
|
||||
//
|
||||
// Until we do that, this conditional (and the weak dependency on webapp that
|
||||
// should really be a strong dependency of the ddp-server package) allows you to
|
||||
// build projects which use `ddp` in Node without wanting to run a DDP server
|
||||
// (ie, allows you to act as if you were using the nonexistent `ddp-client`
|
||||
// server package).
|
||||
if (Package.webapp) {
|
||||
if (process.env.DDP_DEFAULT_CONNECTION_URL) {
|
||||
__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL =
|
||||
process.env.DDP_DEFAULT_CONNECTION_URL;
|
||||
}
|
||||
|
||||
Meteor.server = new Server;
|
||||
|
||||
Meteor.refresh = function (notification) {
|
||||
DDPServer._InvalidationCrossbar.fire(notification);
|
||||
};
|
||||
|
||||
// Proxy the public methods of Meteor.server so they can
|
||||
// be called directly on Meteor.
|
||||
_.each(['publish', 'methods', 'call', 'apply', 'onConnection'],
|
||||
function (name) {
|
||||
Meteor[name] = _.bind(Meteor.server[name], Meteor.server);
|
||||
});
|
||||
} else {
|
||||
// No server? Make these empty/no-ops.
|
||||
Meteor.server = null;
|
||||
Meteor.refresh = function (notification) {
|
||||
};
|
||||
|
||||
// Make these empty/no-ops too, so that non-webapp apps can still
|
||||
// depend on/use packages that use those functions.
|
||||
_.each(['publish', 'methods', 'onConnection'],
|
||||
function (name) {
|
||||
Meteor[name] = function () { };
|
||||
});
|
||||
if (process.env.DDP_DEFAULT_CONNECTION_URL) {
|
||||
__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL =
|
||||
process.env.DDP_DEFAULT_CONNECTION_URL;
|
||||
}
|
||||
|
||||
Meteor.server = new Server;
|
||||
|
||||
Meteor.refresh = function (notification) {
|
||||
DDPServer._InvalidationCrossbar.fire(notification);
|
||||
};
|
||||
|
||||
// Proxy the public methods of Meteor.server so they can
|
||||
// be called directly on Meteor.
|
||||
_.each(['publish', 'methods', 'call', 'apply', 'onConnection'],
|
||||
function (name) {
|
||||
Meteor[name] = _.bind(Meteor.server[name], Meteor.server);
|
||||
});
|
||||
|
||||
// Meteor.server used to be called Meteor.default_server. Provide
|
||||
// backcompat as a courtesy even though it was never documented.
|
||||
// XXX COMPAT WITH 0.6.4
|
||||
|
||||
@@ -35,11 +35,7 @@ StreamServer = function () {
|
||||
// Because we are installing directly onto WebApp.httpServer instead of using
|
||||
// WebApp.app, we have to process the path prefix ourselves.
|
||||
self.prefix = pathPrefix + '/sockjs';
|
||||
// routepolicy is only a weak dependency, because we don't need it if we're
|
||||
// just doing server-to-server DDP as a client.
|
||||
if (Package.routepolicy) {
|
||||
Package.routepolicy.RoutePolicy.declare(self.prefix + '/', 'network');
|
||||
}
|
||||
RoutePolicy.declare(self.prefix + '/', 'network');
|
||||
|
||||
// set up sockjs
|
||||
var sockjs = Npm.require('sockjs');
|
||||
@@ -75,16 +71,16 @@ StreamServer = function () {
|
||||
}
|
||||
|
||||
self.server = sockjs.createServer(serverOptions);
|
||||
if (!Package.webapp) {
|
||||
throw new Error("Cannot create a DDP server without the webapp package");
|
||||
}
|
||||
|
||||
// Install the sockjs handlers, but we want to keep around our own particular
|
||||
// request handler that adjusts idle timeouts while we have an outstanding
|
||||
// request. This compensates for the fact that sockjs removes all listeners
|
||||
// for "request" to add its own.
|
||||
Package.webapp.WebApp.httpServer.removeListener('request', Package.webapp.WebApp._timeoutAdjustmentRequestCallback);
|
||||
self.server.installHandlers(Package.webapp.WebApp.httpServer);
|
||||
Package.webapp.WebApp.httpServer.addListener('request', Package.webapp.WebApp._timeoutAdjustmentRequestCallback);
|
||||
WebApp.httpServer.removeListener(
|
||||
'request', WebApp._timeoutAdjustmentRequestCallback);
|
||||
self.server.installHandlers(WebApp.httpServer);
|
||||
WebApp.httpServer.addListener(
|
||||
'request', WebApp._timeoutAdjustmentRequestCallback);
|
||||
|
||||
// Support the /websocket endpoint
|
||||
self._redirectWebsocketEndpoint();
|
||||
@@ -141,7 +137,7 @@ _.extend(StreamServer.prototype, {
|
||||
// an approach similar to overshadowListeners in
|
||||
// https://github.com/sockjs/sockjs-node/blob/cf820c55af6a9953e16558555a31decea554f70e/src/utils.coffee
|
||||
_.each(['request', 'upgrade'], function(event) {
|
||||
var httpServer = Package.webapp.WebApp.httpServer;
|
||||
var httpServer = WebApp.httpServer;
|
||||
var oldHttpServerListeners = httpServer.listeners(event).slice(0);
|
||||
httpServer.removeAllListeners(event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user