Skip to content

Instantly share code, notes, and snippets.

@betacar
Last active November 7, 2017 15:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betacar/558bd00c324afb88ae50cd81603bf1a5 to your computer and use it in GitHub Desktop.
Save betacar/558bd00c324afb88ae50cd81603bf1a5 to your computer and use it in GitHub Desktop.
NuxtJS plugin to integrate FeathersJS and VueJS
'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