Skip to content
Update Documentation authored by Felix Cervin's avatar Felix Cervin
......@@ -6,6 +6,7 @@
- [Feathers and Nuxt](#feathers-and-nuxt)
- [Feathers JS](#feathers-js)
- [NUXT JS](#nuxt-js)
2. [Boilerplate](#boilerplate)
### General Information
> ##### **Feathers *AND* Nuxt**
......@@ -17,3 +18,38 @@
>> In this boilerplate, I am using Vuex (Vue Store), but I have made kind of a custom "nuxtServerInit". Adding that function will make the site crash.
>> You can also not change the Nuxt application's mode from "SPA" to "Universal" in this boilerplate. This will cause the store mutation "INIT_STORE" to not function, as well as authentication middlewares (Nuxt middlewares) to stop working. You are however free to try to find a different solution, that let's whomever to use either "SPA" or "Universal".
>> [- Major adjustments/changes to the "nuxt.config.js" file sometimes make the application crash. I have yet to find the source of this. Just restart the server whenever this happens. -]
### Boilerplate
> #### **Vue.app**
>> The **Vue.app** object is the Feathers "app" object. Inside **connection.js**, you can find the following code, which is pretty self-explanatory:
>>
```javascript
import Vue from 'vue'
import feathers from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import auth from '@feathersjs/authentication-client'
import io from 'socket.io-client'
try {
Vue.feathers = feathers // This binds "feathers" to the Vue instance.
Vue.socketio = socketio // This binds "feathers socketio" to the Vue instance.
Vue.io = io // This binds "socket.io-client" to the Vue instance.
Vue.auth = auth // This binds "feathers/authentication-client" to the Vue instance.
Vue.socket = await Vue.io( process.env.baseUrl ) // This creates a global socket, on the Vue instance. Usage example: Vue.socket.emit('create', 'users'...)
Vue.app = await Vue.feathers() // This binds the actual important part of feathers to the Vue instance. Usage example: Vue.app.emit(), Vue.app.service('users'), ...
await Vue.app.configure(Vue.socketio(Vue.socket))
await Vue.app.configure(Vue.auth({ entity: 'user', service: 'users', cookie: 'jwt', storage: cookieStorage, storageKey: 'jwt' }))
} catch( error ) {
throw new Error( error )
}
```
>>
>> Basically, "feathers", "socketio", "io" and "auth" are all bound to the Vue object. This makes all of the feathers and socket methods, etc. available in the client *(client/)* side of everything. For more information what these objects contain please see the documentation for each item in Feathers' [documentation](https://docs.feathersjs.com/api/readme.html).
>>> ** Feathers corresponding documentations **
>>> - [Application](https://docs.feathersjs.com/api/application.html)
>>> - [Socket.io-client](https://docs.feathersjs.com/api/client/socketio.html)
>>> - [Authentication-client](https://docs.feathersjs.com/api/authentication/client.html)
\ No newline at end of file