Skip to content

Commit

Permalink
Merge branch 'release-3.0' into feature/ev-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoventurini committed May 16, 2024
2 parents d27946d + 56aa1bb commit 67c3850
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 12 deletions.
18 changes: 18 additions & 0 deletions v3-docs/docs/api/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ login provider packages: `accounts-password`, `accounts-facebook`,

Read more about customizing user accounts in the [Accounts](http://guide.meteor.com/accounts.html) article in the Meteor Guide.

### Accounts with Session Storage {#accounts-session-storage}

By default, Meteor uses Local Storage to store, among other things, login tokens in your browser session. But, for some applications, it makes sense to use Session Storage instead. You can achieve this by adding this to your settings:

```json
{
// ... all other settings,
"public": {
// ... all your public settings
"packages": {
"accounts": {
"clientStorage": "session"
}
}
}
}
```

<ApiBox name="Meteor.user" hasCustomExample/>

Retrieves the user record for the current user from
Expand Down
32 changes: 32 additions & 0 deletions v3-docs/docs/api/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,38 @@ option:
You can pass any MongoDB valid option, these are just examples using
certificates configurations.


### Mongo Oplog Options {#mongo-oplog-options}

> Oplog options were introduced in Meteor 2.15.1
If you set the [`MONGO_OPLOG_URL`](https://docs.meteor.com/environment-variables.html#MONGO-OPLOG-URL) env var, Meteor will use MongoDB's Oplog to show efficient, real time updates to your users via your subscriptions.

Due to how Meteor's Oplog implementation is built behind the scenes, if you have certain collections where you expect **big amounts of write operations**, this might lead to **big CPU spikes on your meteor app server, even if you have no publications/subscriptions on any data/documents of these collections**. For more information on this, please have a look into [this blog post from 2016](https://blog.meteor.com/tuning-meteor-mongo-livedata-for-scalability-13fe9deb8908), [this github discussion from 2022](https://github.com/meteor/meteor/discussions/11842) or [this meteor forums post from 2023](https://forums.meteor.com/t/cpu-spikes-due-to-oplog-updates-without-subscriptions/60028).

To solve this, **2 Oplog settings** have been introduced **to tweak, which collections are *watched* or *ignored* in the oplog**.

**Exclusion**: To *exclude* for example all updates/inserts of documents in the 2 collections called `products` and `prices`, you would need to set the following setting in your Meteor settings file:

```json
"packages": {
"mongo": {
"oplogExcludeCollections": ["products", "prices"]
}
}
```

**Inclusion**: vice versa, if you only want to watch/*include* the oplog for changes on documents in the 2 collections `chats` and `messages`, you would use:

```json
"packages": {
"mongo": {
"oplogIncludeCollections": ["chats", "messages"]
}
}
```

For obvious reasons, using both `oplogExcludeCollections` and `oplogIncludeCollections` at the same time is not possible and will result in an error.

### Mongo.setConnectionOptions(options)

You can also call `Mongo.setConnectionOptions` to set the connection options but
Expand Down
92 changes: 80 additions & 12 deletions v3-docs/v3-migration-docs/breaking-changes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,27 @@ Meteor 3.0 is now using Node v20. This means that if you have any dependencies o
of Node v14, you will need to update them to be compatible with Node v20.


## NPM Installer
## NPM Installer Update

The npm installer has been updated. Use the following command to install Meteor:
The npm installer for Meteor has been changed. For the official release, you can install Meteor with this command:

```bash
npx meteor
```

or
While we’re in the Release Candidate phase, use:

```bash
npx meteor@rc
```

or specify a version directly:

```bash
npx meteor@<version>
```

You should be using a node version >= 20.0.0, if you use in your CI/CD you should update it to use the latest version of Node.
Ensure you're using Node version 20.0.0 or higher, especially in your CI/CD workflows, to be compatible with the latest Meteor version.


## Call x CallAsync
Expand Down Expand Up @@ -104,18 +110,16 @@ await Meteor.callAsync('otherMethod') // [!code highlight]

```

## Changes in Webapp
## WebApp Switches to Express

::: tip

Webapp now uses Express under the hood. This means that you can use all the express features in your Meteor app.

But if you did any customizations in the `WebApp` package, you should check if they are compatible with Express.
WebApp has switched to Express from Connect. This upgrade lets you use all the Express features in your Meteor app.
If you've customized the WebApp package before, please verify if those customizations work with Express.

:::


The `webapp` package now exports this new properties:
The `webapp` package now exports these new properties:

```ts
type ExpressModule = {
Expand Down Expand Up @@ -149,7 +153,9 @@ export declare module WebApp {
// import { WebApp } from 'meteor/webapp';
```

If you want to use express in your app, you can do it like this:
### Routes with WebApp and Express

To add Express routes in your app, check out the [Express Guide](https://expressjs.com/en/guide/routing.html) and follow this example:

```js
import { WebApp } from 'meteor/webapp';
Expand All @@ -172,9 +178,71 @@ import { WebApp } from 'meteor/webapp';
WebApp.handlers.get('/hello', (req, res) => {
res.send('Hello World');
});
```

### Middlewares with WebApp and Express

To include **Router-level** Express middleware in your app, check out the [Express Guide](https://expressjs.com/en/guide/using-middleware.html#middleware.router) and follow this example:

```js
import { WebApp } from 'meteor/webapp';

const app = WebApp.express();
const router = WebApp.express.Router();

// This middleware is executed every time the app receives a request
router.use((req, res, next) => {
console.log('Router-level - Time:', Date.now());
next();
})

// This middleware shows request info for any type of HTTP request to the /hello/:name path
router.use('/hello/:name', (req, res, next) => {
console.log('Router-level - Request URL:', req.originalUrl);
next();
}, (req, res, next) => {
console.log('Router-level - Request Type:', req.method);
next();
})

// mount the router on the app
app.use('/', router);

WebApp.handlers.use(app);
```

To include **Application-level** Express middleware in your app, check out the [Express Guide](https://expressjs.com/en/guide/using-middleware.html#middleware.application) and follow this example:

```js
import { WebApp } from 'meteor/webapp';

const app = WebApp.express();
const router = WebApp.express.Router()

// This middleware is executed every time the app receives a request
router.use((req, res, next) => {
console.log('Router-level - Time:', Date.now());
next();
})

// This middleware shows request info for any type of HTTP request to the /hello/:name path
router.use('/hello/:name', (req, res, next) => {
console.log('Router-level - Request URL:', req.originalUrl);
next();
}, (req, res, next) => {
console.log('Router-level - Request Type:', req.method);
next();
})

// mount the router on the app
app.use('/', router);

WebApp.handlers.use(app);
```
Changed engine from connect to express and changed api naming to match express. See below:

### New API Names

Having switched from Connect to Express, we updated API names to align with Express. See the details below:
- `WebApp.connectHandlers.use(middleware)` is now `WebApp.handlers.use(middleware)`
- `WebApp.rawConnectHandlers.use(middleware)` is now `WebApp.rawHandlers.use(middleware)`
- `WebApp.connectApp` is now `WebApp.expressApp`
Expand Down

0 comments on commit 67c3850

Please sign in to comment.