Hey there!
My Meteor app uses a package-only structure, and now I’m about to add a collection-fs
package, that manages my files.
For the collection, I’m adding two files, one for the client, one for the server. Both define a PDFs
variable, which I then export. The problem is, that I get the var on the server, but not on the client.
This is my code:
// package.js
Package.onUse(function (api) {
var c = 'client';
var s = 'server';
// Core Dependencies
api.use([
'coffeescript'
]);
// Atmosphere Dependencies
api.use([
'cfs:standard-packages@0.5.8',
'cfs:filesystem@0.1.2',
'cfs:s3@0.1.3'
]);
// Collections
api.addFiles('collections/pdfs/collection_client.coffee', c);
api.addFiles([
'collections/pdfs/collection_server.coffee',
'collections/pdfs/allow_deny.coffee'
], s);
// Methods
api.addFiles('methods/pdfs/server.coffee', s);
// Exports
api.export('PDFs');
});
### Client (collections/pdfs/collection_client.coffee) ###
PDFs = new FS.Collection 'pdfs',
stores: [
new FS.Store.S3 'pdfs'
]
### Server (collections/pdfs/collection_server.coffee) ###
access = Meteor.settings.amazon
PDFs = new FS.Collection 'pdfs',
stores: [
new FS.Store.S3 'pdfs',
bucket: 'app-development'
accessKeyId: access.accessKeyId
secretAccessKey: access.secretAccessKey
region: 'eu-central-1'
]
I’ve not converted to JavaScript here, because I don’t know if it’s some Meteor - CoffeeScript thing causing my problem.
When I open the browser console and run PDFs
, expecting an Object, I get undefined
. Package['collection-fs'].PDFs
however returns it correctly.
Why doesn’t my PDFs
object get added to the window
namespace?