You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial/simple-todos/09-methods.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Meteor Method is a way to communicate with your server using the function `Meteo
12
12
13
13
> You can read more about Methods [here](https://guide.meteor.com/methods.html).
14
14
15
-
## 8.1: Disable Quick Prototyping
15
+
## 9.1: Disable Quick Prototyping
16
16
17
17
Every newly created Meteor project has the `insecure` package installed by default.
18
18
@@ -26,7 +26,7 @@ meteor remove insecure
26
26
27
27
Now your app changes don't work anymore as you have revoked all client-side database permissions. Try to insert a new task for example, you are going to see `insert failed: Access denied` in your browser console.
See that you don't need to get any symbol back from the import, you only need to ask for your server to import the file then `Meteor.methods` will be evaluated and will register your methods on server startup.
116
116
117
-
## 8.3: Implement Method Calls
117
+
## 9.3: Implement Method Calls
118
118
119
119
As you have defined your methods, you need to update the places we were operating the collection to use them instead.
120
120
@@ -173,7 +173,7 @@ Now your inputs and buttons will start working again. What have you gained?
173
173
1. We can add extra validation logic to the methods later if we want.
174
174
1. Our client code is more isolated from our database logic. Instead of a lot of stuff happening in our event handlers, we have methods callable from anywhere.
175
175
176
-
## 8.4: api and db folders
176
+
## 9.4: api and db folders
177
177
178
178
We would like to take a moment here to think, the folder where the collection file is located is `api` but API in your project means a communication layer between server and client but the collection is not performing this role anymore. So you should move your `TasksCollection` file to a new folder called `db`.
Copy file name to clipboardExpand all lines: tutorial/simple-todos/10-publications.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: '10: Publications'
4
4
5
5
Now we have moved all of our app's sensitive code into methods, we need to learn about the other half of Meteor's security story. Until now, we have worked assuming the entire database is present on the client, meaning if we call `Tasks.find()` we will get every task in the collection. That's not good if users of our application want to store privacy-sensitive data. We need a way of controlling which data Meteor sends to the client-side database.
6
6
7
-
## 9.1: autopublish
7
+
## 10.1: autopublish
8
8
9
9
Just like with `insecure` in the last step, all new Meteor apps start with the `autopublish` package, which automatically synchronizes all the database contents to the client. So you should remove it:
10
10
@@ -17,7 +17,7 @@ When the app refreshes, the task list will be empty. Without the `autopublish` p
17
17
-`Meteor.publish`: allows the data to be published from the server to the client;
18
18
-`Meteor.subscribe`: allows the client code to ask for data to the client.
19
19
20
-
## 9.2: Tasks Publication
20
+
## 10.2: Tasks Publication
21
21
22
22
You need to add first a publication to your server, this publication should publish all the tasks from the authenticated user. As in the `Methods` you can also use `this.userId` in publication functions to get the authenticated `userId`.
Then we can subscribe to that publication in the client.
54
54
@@ -84,7 +84,7 @@ It's also a good moment for us to refactor our code to use a single `useTracker`
84
84
..
85
85
```
86
86
87
-
## 9.4: Loading state
87
+
## 10.4: Loading state
88
88
89
89
You should also add a loading state for your app, that means, while the subscription data is not ready you should inform to your user. To discover if the subscription is ready or not you should get the return of the `subscribe` call, it is an object with the subscription state including the `ready` function that will return a `boolean`.
90
90
@@ -125,7 +125,7 @@ Once you have done this, all the tasks will reappear.
125
125
126
126
Calling `Meteor.publish` on the server registers a publication named `tasks`. When `Meteor.subscribe` is called on the client with the publication name, the client subscribes to all the data from that publication, which in this case is all the tasks in the database for the authenticated user.
127
127
128
-
## 9.5: Check User Permission
128
+
## 10.5: Check User Permission
129
129
130
130
Only the owner of a task should be able to change certain things. You should change your methods to check if the user that is authenticated is the same user that created the tasks.
Copy file name to clipboardExpand all lines: tutorial/simple-todos/11-running-on-mobile.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Meteor makes it easy to set up all the tools required to build mobile apps, but
10
10
11
11
> Important: Mobile set up and settings are very dynamic, if you find any step below not working as specified or any linked document that is not up-to-date, please open an issue, and we are going to update it. You can also open PRs if you know what the change should be.
12
12
13
-
## 10.1: iOS Simulator
13
+
## 11.1: iOS Simulator
14
14
15
15
If you have a Mac, you can run your app inside the iOS simulator.
16
16
@@ -27,7 +27,7 @@ You will see the iOS simulator pop up with your app running inside.
First, complete all the steps above to set up the Android tools on your system. Then, make sure you have [USB Debugging](http://developer.android.com/tools/device.html#developer-device-options) enabled on your phone and it is plugged into your computer with a USB cable. Also, you must quit the Android emulator before running on a device.
53
53
@@ -59,7 +59,7 @@ meteor run android-device
59
59
60
60
The app will be built and installed on your device.
However, if you would prefer to split your tests across multiple modules, you can do that too. Add a new test module called `imports/api/tasksMethods.tests.js`.
45
45
@@ -65,7 +65,7 @@ And import it on `tests/main.js` like `import '/imports/api/tasksMethods.tests.j
65
65
import'/imports/api/tasksMethods.tests.js';
66
66
```
67
67
68
-
## 11.3: Prepare Database
68
+
## 12.3: Prepare Database
69
69
70
70
In any test you need to ensure the database is in the state we expect before beginning. You can use Mocha's `beforeEach` construct to do that easily:
71
71
@@ -97,7 +97,7 @@ if (Meteor.isServer) {
97
97
98
98
Here you are creating a single task that's associated with a random userId that'll be different for each test run.
99
99
100
-
## 11.4: Test Task Removal
100
+
## 12.4: Test Task Removal
101
101
102
102
Now you can write the test to call the `tasks.remove` method as that user and verify the task got deleted, as you are going to test a method and we want to mock the authenticated user you can install this utility package to make your life easier:
103
103
@@ -142,7 +142,7 @@ if (Meteor.isServer) {
142
142
143
143
Remember to import `assert` from `chai` (`import { assert } from 'chai';`)
144
144
145
-
## 11.5: More tests
145
+
## 12.5: More tests
146
146
147
147
You can add as many tests you want, below you can find a few other tests that can be helpful for you to have more ideas of what to test and how.:
Copy file name to clipboardExpand all lines: tutorial/simple-todos/13-deploying.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The best place to run your Meteor app is [Galaxy](https://www.meteor.com/cloud).
8
8
9
9
> If you have any trouble with this step you should send an email to Galaxy support and they are going to help you, send your message to `support@meteor.com`. Try to explain in detail what is the issue and you are going to receive help as soon as possible. Also make sure you include the subject: `React Tutorial` so you know where are you coming from.
10
10
11
-
## 12.1: Create your account
11
+
## 13.1: Create your account
12
12
13
13
Do you have a Meteor Cloud Account? No? Ok, let's fix it.
14
14
@@ -20,7 +20,7 @@ Sign up with GitHub and proceed from there. It's just going to ask you an userna
20
20
21
21
Done, your account is created. You can use this account to access [atmospherejs.com](https://atmospherejs.com/), [Forums](https://forums.meteor.com), and much more including Galaxy free deploy.
22
22
23
-
## 12.2: Deploy it
23
+
## 13.2: Deploy it
24
24
25
25
Now you are ready to deploy, make sure you run `meteor npm install` before deploying to make sure all your dependencies are installed.
26
26
@@ -63,12 +63,14 @@ This process usually takes around 5 minutes but it depends on your internet spee
63
63
64
64
You can check your logs on Galaxy, including the part that Galaxy is building your Docker image and deploying it.
65
65
66
-
## 12.3: Access and enjoy
66
+
## 13.3: Access and enjoy
67
67
68
68
Now you should be able to access your Galaxy dashboard at `https://galaxy.meteor.com/app/react-tutorial.meteorapp.com` (replacing `react-tutorial` with your sub-domain)
69
69
70
70
And, of course, be able to access and use your app in the domain that you chose, in our case here [react-tutorial.meteorapp.com](http://react-tutorial.meteorapp.com). Congrats!
71
71
72
+
Don't forget to update your URLs on Github OAuth Application. Find your application on [this link](https://github.com/settings/developers), and update the `Homepage URL` and `Authorization callback URL` to your app domain, in our case [react-tutorial.meteorapp.com](http://react-tutorial.meteorapp.com)
73
+
72
74
> We deployed to Galaxy running in the US (us-east-1), we also have Galaxy running in other regions in the world, check the list [here](https://cloud-guide.meteor.com/deploy-region.html)
73
75
74
76
This is huge, you have your Meteor app running on Galaxy, ready to be used by anyone in the world!
0 commit comments