Dennis
Dennis

Reputation: 33

Meteor file system

I have a question about meteor file structure. I´m coming from JAVA so maybe I'm thinking way too complicated.

When you create a new Meteor project (using osx shell), it creates you a folder like /usr/MyUsername/projectname/.

Inside you'll find the: project.js, project.html, project.css and the .meteor folder.

What I want to do now is:

Create a structure like: /usr/MyUsername/projectname/

There I want to create a server an a client folder. where I put the client.js and the server.js into.

Where do I set the references? For example with the following code in the project/client/client.js:

Meteor.call('somefunc', someobj);

I have in the project/server/server.js the following code:

if (Meteor.isServer) {
  Meteor.startup(function () {
    Meteor.methods({
      'somefunc':function(someobj){
        CalEvent.insert(someobj);
      }
    })
  });
}

Where in the client.js do I tell where the server.js is? and how?

Upvotes: 2

Views: 158

Answers (1)

saimeunt
saimeunt

Reputation: 22696

Long story short : you don't have to worry about references, as long as you put things that belong in the client under client/ and server-side stuff under server/ you're good to go.

No need to wrap your code with Meteor.isServer blocks if it lives under server/. You don't need the Meteor.startup block either, the code you put in these sections is rerun everytime the server is restarted but you only need your method to be defined once.

The meteor tool build process takes care of merging all the client files and sends them to the browser for execution, likewise it's merging server files and spawn a Node.js process to execute the resulting bundle.

Upvotes: 1

Related Questions