Methods and File Structure

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?

1 Like

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

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

1 Like

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

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

1 Like