Methods and File Structure


#1

I want to define my Meteor Methods in a separate “methods.jsx” file that’s in a separate folder for every collection. For a collection named “ExampleCollection,” the structure would be API -> ExampleCollection -> Methods.jsx. This would follow the file structure recommended here in the docs: http://guide.meteor.com/structure.html

When I try to do this, however, the server is unable find the methods. But it works fine in a big methods.jsx folder one level higher. (API -> methods.jsx.)

Is there a special import/export to make the ExampleColelction folder or methods.jsx file visible to the server?


#2

You need to import the methods from a server file, otherwise they are not registered on the server.


#3

I see - I created a file called server/register-apis.jsx, imported the
files, and it’s working now. Thanks!


#4

Please make a PR to the guide to make this clearer!


#5

Sounds good! Added this language to the section that describes the approach of creating an individual directory for each collection.