Last active
November 7, 2017 15:49
-
-
Save betacar/558bd00c324afb88ae50cd81603bf1a5 to your computer and use it in GitHub Desktop.
NuxtJS plugin to integrate FeathersJS and VueJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import Vue from 'vue'; | |
import Feathers from 'feathers/client'; | |
import VueFeathers from 'vue-feathers'; | |
import hooks from 'feathers-hooks'; | |
import authentication from 'feathers-authentication/client'; | |
// import rest from 'feathers-rest/client'; | |
import rx from 'feathers-reactive'; | |
import RxJS from 'rxjs'; | |
// import axios from 'axios'; | |
import socketio from 'feathers-socketio/client'; | |
import io from 'socket.io-client'; | |
if (process.BROWSER_BUILD) { | |
// Configure Feathers client | |
const host = process.env.FEATHERS_HOST || 'http://localhost:3030'; | |
const socket = io(host); | |
const feathers = Feathers() | |
.configure(authentication({storage: this.localStorage})) | |
.configure(socketio(socket)) | |
// .configure(rest(host).axios(axios)) | |
.configure(rx(RxJS)) | |
.configure(hooks()); | |
Vue.use(VueFeathers, feathers); | |
} | |
// The feathers instance will be available | |
// as this.$nuxt.$feathers, instead of this.$feathers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment