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: docs/common-patterns.md
+285Lines changed: 285 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -507,3 +507,288 @@ export default new Vuex.Store({
507
507
## Enable Debug Logging
508
508
509
509
If items aren't not getting added to the store properly, try setting the `debug` option on the `makeServicePlugin` to `true`. It enables some additional logging that may be useful for troubleshooting.
510
+
511
+
## Full nuxt example
512
+
513
+
In this example we will create a nuxt configuration with all the features discribed in the [Nuxt Section](./nuxt.md).
514
+
515
+
Our application is hosted in 2 different endpoints, one for the feathers api and another with our nuxt SSR, and we will also implement a permission system that will prevent users without an `admin` permission to get into some pages. For that you will need to [customize your payload](https://docs.feathersjs.com/cookbook/authentication/stateless.html#customizing-the-payload) in your feathers api.
The `admin` middleware will redirect any user that is not loged in or do not have the `admin` permission to a `not-permited` page.
557
+
558
+
```js
559
+
// ~/middleware/admin.js
560
+
exportdefaultfunction ({ store, redirect }) {
561
+
const { auth } =store.state
562
+
constpermissions=auth.payload.permissions
563
+
if (
564
+
!auth.payload||
565
+
!permissions.includes('admin')
566
+
) {
567
+
returnredirect('/not-permited')
568
+
}
569
+
}
570
+
```
571
+
Add the `admin` middleware to the administrative pages
572
+
573
+
```js
574
+
// ~/pages/**
575
+
exportdefault {
576
+
577
+
...
578
+
579
+
middleware: ['admin']
580
+
581
+
...
582
+
583
+
}
584
+
```
585
+
586
+
In the feathers client configuration we will use a different transport for the nuxt-server > api comunication and the nuxt-client > api. When we are making request on the server we do not need the socket io realtime messaging system so we can use an rest configuration for better performance.
Copy file name to clipboardExpand all lines: docs/model-classes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ One important note, the `isAdmin` attribute is specified in the above example in
146
146
147
147
A new `setupinstance` class method is now available in version 2.0. This method allows you to transform the data and setup the final instance based on incoming data. For example, you can access the `models` object to reference other service Model classes and create data associations.
148
148
149
-
The function will be called with the following arguments and should return an object of default properties for new instances.
149
+
The function will be called during model instance construction with the following arguments and should return an object containing properties that'll be merged into the new instance.
150
150
151
151
-`data {Object}` - The instance data
152
152
- A `utils` object containing these props:
@@ -160,7 +160,7 @@ For an example of how you might use `setupInstance`, suppose we have two service
0 commit comments