
More recently, I came across a very ambitious project
Meteor . I was bribed by its simplicity and speed of application development on it. This article will show some "tricks" and useful tips such as installing custom packages, adding jquery plug-ins to a project, deploying a project on a combat server, and so on.
This post is intended for those who already have minimal experience in working with Meteor.
1. How to install custom packages?
Install
Meteorite . Meteorite is needed for convenient installation of packages. The list of packages is not yet large and is available by
reference .
Here is the sequence of steps:
1. to install Meteorite, install node.js first by downloading from
nodejs.org2. perform
sudo npm install -g meteorite
3. After that, the packages can be installed to add using the mrt install packagename | mrt add packagename, for example
mrt install jquery-ui | mrt add jquery-ui
')
The syntax for working with Meteorite is identical to Meteor. To use and debug your packages, simply put them in the packages directory.
2. How to use jQuery plugins?
Very often there is a situation when you need to use some kind of plugin for jQuery, but it is not yet in the packages.
This is done simply:
1. download the necessary plugin, unpack udilyaem * .min.js (or uncompressed version), so that the code of the plugin is not connected twice
2. create the client / lib folder in the application root and put the plugin there along with the css
3. How to implement API based on Meteor?
If you suddenly wanted to organize an API (for example, interaction with mobile devices), you will have to use the following hack:
1. create file /server/api.js
2. add the following code there
3. now when accessing
http: // localhost: 3000 / test will be given to json
4. How to deploy correctly?
Deploy very easy. For efficient production, you need to install mongodb, nodejs and I recommend installing
supervisior for the stable operation of the application. After this, perform the following steps:
1. edit the file environment variables sudo vim / etc / environment (in the case of Ubuntu), add PORT = 3000 MONGO_URL = mongodb: // localhost: 27017 / test, these variables store the port on which the project will hang and the settings for connecting to mongodb
2. on the client doing
mrt bundle project.tgz
and fill it in with production
3. we unpack the project on production
tar zxvf project.tgz
4. perform
supervisor node < >/bundle/main.js
and open the application on port 3000, everything should work
5. There was a question, but the documentation is still not enough?
Communicate actively on Stackoverflow on the
meteor tag - you will usually be answered quickly and this can save you some time. In my case, issues are solved in a maximum of 12 hours.