How to use @feathersjs/socketio-client - 10 common examples

To help you get started, we’ve selected a few @feathersjs/socketio-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quasarframework / app-extension-feathersjs / src / templates / base / src / api / feathers.js View on Github external
import Vue from 'vue'
import createApplication from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import authentication from '@feathersjs/authentication-client'
import io from 'socket.io-client'

const socket = io(process.env.API_BASE_URL, {
  transports: ['websocket']
})
const feathers = createApplication()

feathers.configure(socketio(socket))
feathers.configure(authentication({
  header: 'Authorization', // the default authorization header for REST
  path: '/api/authentication', // the server-side authentication service path
  jwtStrategy: 'jwt', // the name of the JWT authentication strategy
  entity: 'user', // the entity you are authenticating (ie. a users)
  service: 'users', // the service to look up the entity
  cookie: 'feathers-jwt', // the name of the cookie to parse the JWT from when cookies are enabled server side
  storageKey: 'feathers-jwt', // the key to store the accessToken in localstorage or AsyncStorage on React Native
  storage: window.localStorage // Passing a WebStorage-compatible object to enable automatic storage on the client.
}))

Vue.prototype.$feathers = feathers

export default feathers
github timmo001 / home-panel / src / Components / Root.js View on Github external
progressRoot: {
    position: 'absolute',
    top: '50%',
    left: '50%'
  }
});

const app = feathers();
const socket = io(
  `${process.env.REACT_APP_API_PROTOCOL || window.location.protocol}//${process
    .env.REACT_APP_API_HOSTNAME || window.location.hostname}:${process.env
    .REACT_APP_API_PORT || 3234}`
);

// Setup the transport (Rest, Socket, etc.) here
app.configure(socketio(socket));

// Available options are listed in the "Options" section
app.configure(auth({ storage: localStorage }));

let connection;

class Root extends React.PureComponent {
  state = {
    snackMessage: { open: false, text: '' },
    connected: false,
    hass_url:
      localStorage.getItem('hass_url') ||
      `${window.location.protocol}//hassio:8123`
  };

  componentDidMount = () => this.login();
github DefinitelyTyped / DefinitelyTyped / types / feathersjs__socketio-client / feathersjs__socketio-client-tests.ts View on Github external
import feathers, { Application } from '@feathersjs/feathers';
import feathersSocketIOClient from '@feathersjs/socketio-client';

import * as io from 'socket.io-client';

const socket = io();
const app: Application = feathers();

app.configure(feathersSocketIOClient(socket));
app.configure(feathersSocketIOClient(socket, { timeout: 1337 }));
github nesterow / frontless / src / client.js View on Github external
error: (context) => {
    if (typeof window !== 'undefined') {
      const {name} = context.service;
      evbus.emit('request:error', context)
      evbus.emit(name+':error', context)
    }
  }
};

const endpoint = 'http://localhost:8000';

const app = feathers()
if (typeof window !== 'undefined') {
  const ws = io(endpoint)
  const wsc = feathers()
  wsc.configure(socketio(ws, {
    timeout: 2000,
  }));
  wsc.hooks(hooks)
  app.io = wsc
  app.ws = ws
  
}

const rest = feathers.rest(endpoint)

app.configure(rest.axios(axios))
app.hooks(hooks)


export default app
github timmo001 / home-panel / src / Components / Onboarding.tsx View on Github external
useEffect(() => {
    if (!client) {
      client = feathers();
      let path: string = clone(props.location.pathname);
      let url: string = `${process.env.REACT_APP_API_PROTOCOL ||
        window.location.protocol}//${process.env.REACT_APP_API_HOSTNAME ||
        window.location.hostname}:${
        process.env.REACT_APP_API_PORT || process.env.NODE_ENV === 'development'
          ? '8234'
          : window.location.port
      }`;
      socket = io(url, { path: `${path}/socket.io`.replace('//', '/') });
      client.configure(socketio(socket));
      client.configure(authentication());
    }
  }, [props.location]);
github claustres / quasar-feathers-tutorial / quasar-feathers / src / api.js View on Github external
import feathers from '@feathersjs/feathers'
import socketio from '@feathersjs/socketio-client'
import auth from '@feathersjs/authentication-client'
import io from 'socket.io-client'

const socket = io('http://localhost:8081', {transports: ['websocket']})

const api = feathers()
  .configure(socketio(socket))
  .configure(auth({ storage: window.localStorage }))

api.service('/users')
api.service('/messages')

export default api
github silvestreh / feathers-nuxt / client / feathers-client.js View on Github external
import feathers from '@feathersjs/feathers';
import socketio from '@feathersjs/socketio-client';
import auth from '@feathersjs/authentication-client';
import io from 'socket.io-client';
import { CookieStorage } from 'cookie-storage'

const storage = new CookieStorage();
const socket = io(process.env.apiURL, { transports: ['websocket'] });
const app = feathers()
  .configure(socketio(socket))
  .configure(auth({ storage }));

export default app;
github nesterow / frontless / src / lib / client.js View on Github external
}],
  },
};

const endpoint = process.settings.origin;


const ws = io(endpoint);
const rest = feathers.rest(endpoint);

const app = feathers();
const wsc = feathers();


app.configure(rest.axios(axios));
wsc.configure(socketio(ws, {
  timeout: 2000,
}));

wsc.hooks(hooks);
app.hooks(hooks);
app.io = wsc;
app.ws = ws;

export default app;
github CodingGarden / trello-clone / client / src / feathers-client.js View on Github external
import socketio from '@feathersjs/socketio-client';
import auth from '@feathersjs/authentication-client';
import io from 'socket.io-client';

let API_URL = 'https://cg-trello-clone.now.sh';

if (window.location.hostname === 'localhost') {
  API_URL = 'http://localhost:3030';
}

const socket = io(API_URL, {
  transports: ['websocket'],
});

const feathersClient = feathers()
  .configure(socketio(socket))
  .configure(auth({
    storage: window.localStorage,
  }));

export default feathersClient;

@feathersjs/socketio-client

The client for Socket.io through feathers-socketio

MIT
Latest version published 24 days ago

Package Health Score

92 / 100
Full package analysis

Popular @feathersjs/socketio-client functions