Reputation: 6459
I'm trying to understand Meteor as I create a project and I find some things a little difficult to understand so far.
1- When they say I can create a server
and a client
folder, where exactly I am meant to do so? Sibling of .meteor
? And will everything be at client's or server's scope when the app starts or do I have to do something else? If I create a foo.js
and a foo
function inside it in client
folder, can I just call foo()
in Meteor.isClient
and it will work?
2- I need to create an upload folder so people can upload their stuff (images). So where am I supposed to do this? Plus, how can I get the absolute path to my project and find this upload
folder inside?
During my attempts I tried the following:
fs = Meteor.npmRequire('fs');
__ROOT_APP_PATH__ = fs.realpathSync('.');
But __ROOT_APP_PATH__
is .meteor\local\build\programs\server
. Quite hidden right?!
3- I saw some people uploading and saving files on MongoDB directly. This is something we usually don't do with relational databases. We move the file to a known folder on a CDN or on our own disk and save the hash or name of that file so we can easily find it. Isn't it encouraged with Meteor + MongoDB? Why would I save the file itself on Mongo instead of moving it to a folder?
Upvotes: 2
Views: 589
Reputation: 552
FOLDER STRUCTURE:
both/ (OR lib/) -- common code for server and client
|- collections/ -- declare collections (e.g Employer = new Meteor.Collection("employer");)
|- router / -- router code(e.g Router.route(..))
client/ -- client side code
|- global/ -- all global variable for client
|- helpers/ -- global helper for client (for all templates)
|- plugins/ -- all the plugins code(if you use any)
|- stylesheets/ -- css / less files
|- templates/ -- all templates
|- home.html -- home template(html)
|- home.js -- home template(js)
public/ -- images/icons/fonts (meteor looking at this file)
server/ -- server code
|- methods/ -- server methods/API (e.g Meteor.methods({...}))
|- publish/ -- publish code from server
this is the basic folder structure for meteor project which i follow. For further reference or Documentation. For any question feel free ask in comments..
Upvotes: 3
Reputation: 2090
not any specific way to do but meteor recommend it doing this way http://docs.meteor.com/#/basic/filestructure
Upvotes: 3