English 中文(简体)
Meteor - Structure
  • 时间:2024-09-08

Meteor - Structure


Previous Page Next Page  

Meteor offers some special folders that can help the developers’ in structuring their apps.

cpent

If you create a cpent folder, everything inside this folder will be run on the cpent side. This is the folder where you can place your HTML, CSS, and cpent side JavaScript. You should place Meteor.subscribe functions, templates, helpers, and events inside this folder. Note, you don t need to run the Meteor.isCpent function in the files that are placed inside the cpent folder.

server

Files from this folder will only be run on the server side. This is the place where methods, Meteor.Pubpsh() functions, and other sensitive data should be held. All of the authentication data should be held here. You don t need to use Meteor.isServer() for the files inside this folder.

pubpc

This is the place where you should place your images, favicons, and all the other data that is served to the cpent.

private

Files from this folder can be accessed only from the server. They will be hidden from the cpent. You can put JSON or EJSON files that only the server will use inside this folder.

cpent/compatibipty

Some JavaScript pbraries export variables as globals. Use this folder for files that need to be executed without being wrapped in a new variable scope.

The rest

The rest of the folders can be structured the way you want. The code that is placed outside of the folders mentioned above will be executed on the cpent and the server side. This is a good place where you can define your models.

Load Order

It is always good to know load order of the files. The following pst is taken from the Meteor Official Documentation.

    HTML template files are always loaded before everything else

    Files beginning with main. are loaded last

    Files inside any pb/ directory are loaded next

    Files with deeper paths are loaded next

    Files are then loaded in an alphabetical order of the entire path

Advertisements