Exemplo n.º 1
0
export default function thingMiddleware(a, req) {
  let app = undefined;
  if(__SERVER__) {
    app = req.app;
  } else {
    console.log("client");
    const feathers = require('feathers/client')
    const socketio = require('feathers-socketio/client');
    const hooks = require('feathers-hooks');
    const io = require('socket.io-client');

    const socket = io();
    app = feathers()
      .configure(hooks())
      .configure(socketio(socket));
  }
  
  const todos = app.service('todos');  
  todos.get(1).then((todo) => {
    console.log(todo);
  });
  
  return next => action => {
    if (typeof action === 'function') {
      return action(dispatch, getState);
    }
      
    return next(action);
  };
}
 it('authenticates via Socket.io', done => {
   const app = feathers()
     .configure(socketio(socket))
     .configure(hooks())
     .configure(authentication())
     .use('/storage', memory());
   
   socket.on('connect', () => {
     app.authenticate({
       type: 'local',
       email, password
     }).then(response => {
       assert.ok(response.token);
       assert.ok(response.data);
       
       app.user()
         .then(user => {
           assert.deepEqual(user, response.data);
           
           return app.token();
         })
         .then(token => assert.deepEqual(token, response.token))
         .then(done);
     }).catch(done);
   });
 });
Exemplo n.º 3
0
function FeathersService() {
  this.app = feathers()
    .configure(socketio(socket))
    .configure(hooks());

  this.stateService = StateService;

  this.stockService = this.app.service('stock');
}
Exemplo n.º 4
0
    constructor(props) {
        super(props);
        const options = {transports: ['websocket'], forceNew: true};
        this.socket = io('http://localhost:3030', options);

        this.state = {connected: false};
        this.app = feathers()
            .configure(socketio(this.socket))
            .configure(hooks())
            .use('storage', localstorage({storage: AsyncStorage}))
            .configure(authentication());
    }
Exemplo n.º 5
0
  constructor(props, context) {
    super(props, context);

    // this.state = {};

    const options = { transports: ['websocket'], forceNew: true };
    const socket = io('http://localhost:3030', options);
    this.app = feathers()
      .configure(socketio(socket))
      .configure(hooks())
      .configure(authentication({
        storage: AsyncStorage,
      }));
  }
  constructor(props) {
    super(props);
    this.showsidemenu = this.showsidemenu.bind(this);
    this.renderLeftButton = this.renderLeftButton.bind(this);

    const options = {transports: ['websocket'], forceNew: true};
    const socket = io('http://localhost:3030', options);

    this.state = { connected: false };

    this.app = feathers()
      .configure(socketio(socket))
      .configure(hooks())
      // Use AsyncStorage to store our login toke
      .configure(authentication({
        storage: AsyncStorage
      }));
  }
  constructor(props, context) {
    super(props, context);
    const options = {
      transports: ['websocket'],
      forceNew: true,
      reconnection: true,
      reconnectionDelay: props.reconnectionDelay,
      reconnectionDelayMax: props.reconnectionDelayMax,
    };
    const socket = io(props.wsEndpoint, options);
    this._initialized = false;
    this._connected = false;
    this._timeout = null;

    this.app = feathers()
    .configure(socketio(socket, { timeout: props.timeout }))
    .configure(hooks())
    .configure(authentication({ storage: AsyncStorage }));
  }
export function createApp(req) {
  if (req === 'rest') {
    return configureApp(rest(host('/api')).superagent(superagent));
  }

  if (__SERVER__ && req) {
    const app = configureApp(rest(host('/api')).superagent(superagent, {
      headers: {
        Cookie: req.get('cookie'),
        authorization: req.header('authorization') || ''
      }
    }));

    const accessToken = req.header('authorization') || (req.cookies && req.cookies['feathers-jwt']);
    app.set('accessToken', accessToken);

    return app;
  }

  return configureApp(socketio(socket));
}
Exemplo n.º 9
0
'use strict';

import feathers from 'feathers/client';
import hooks from 'feathers-hooks';
import socketio from 'feathers-socketio/client';
import auth from 'feathers-authentication/client';
import io from 'socket.io-client';
import config from '../config';

// connect to feathersJS server
const socket = io( config.SERVER_URL );

export const feathers_socket = feathers()
    .configure( socketio( socket ) )
    .configure( hooks() )
    .configure( auth( { storage: window.localStorage } ) );

// services
export const userService = feathers_socket.service( 'users' );
export const messageService = feathers_socket.service( 'messages' );
 function SocketService() {
     this.socket = io(HOST);
     this._app = feathers()
         .configure(socketio(this.socket))
         .configure(hooks());
 }
 setupTests(() => {
   return feathers()
     .configure(socketio(socket))
     .configure(hooks())
     .configure(authentication());
 });
Exemplo n.º 12
0
import io from 'socket.io-client';
import feathers from 'feathers/client';
import hooks from 'feathers-hooks';
import socketio from 'feathers-socketio/client';
import authentication from 'feathers-authentication-client';

const url = liane.server;

const socket = io(url);

const client = feathers();
client.configure(hooks());
client.configure(socketio(socket));
client.configure(authentication({
  storage: localStorage
}));

export default client;
Exemplo n.º 13
0
var FormGroup = require('react-bootstrap/lib/FormGroup');
var FormControl = require('react-bootstrap/lib/FormControl');
var ListGroupItem = require('react-bootstrap/lib/ListGroupItem');
var Button = require('react-bootstrap/lib/Button');
var ButtonGroup = require('react-bootstrap/lib/ButtonGroup');
//var Glyphicon = require('react-bootstrap/lib/Glyphicon');
var ControlLabel = require('react-bootstrap/lib/ControlLabel');
var Grid = require('react-bootstrap/lib/Grid');
var Row = require('react-bootstrap/lib/Row');
var Col = require('react-bootstrap/lib/Col');
//var BarCharts = require('BarChart');
var Chart = require('react-google-charts').Chart;

const socket = io('https://cardif-workspace-fedevela.c9users.io/');

const app = feathers().configure(socketio(socket)).configure(hooks()).configure(authentication({storage: window.localStorage}));

// A placeholder image if the user does not have one
const PLACEHOLDER = 'https://placeimg.com/60/60/people';
// An anonymous user if the servicioRegistroVentas does not have that information
const dummyUser = {
  avatar: PLACEHOLDER,
  email: 'Anonymous'
};

//data= {[ { value: 30, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 10, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 25, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 40, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 2, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 5, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 33, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 13, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 49, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 32, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2},{ value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2}, { value: 0, high: 50, low:0, unitHeight: 3, barItemTop: 0, barInterval: 2} ]};

const FormMessages = React.createClass({
  getInitialState() {
    return {value: ''};
  },
Exemplo n.º 14
0
// Messages fixtures
var messageAlgebra = new set.Algebra(
		set.props.id('_id')
);
var messageStore = fixture.store([], messageAlgebra);


// Run basic tests for the feathers-rest provider.
clearCookies();
runCrossProviderTests({
	moduleName: 'feathers-rest',
	provider: rest('').jquery(jQuery),
	fixtures: function(){
		fixture('/messages', messageStore);
	}
});

// Run basic tests for the feathers-socketio provider.
var socket = io('', {
	transports: ['websocket']
});
var socketioProvider = socketio(socket);
clearCookies();
runCrossProviderTests({
	moduleName: 'feathers-socketio',
	provider: socketioProvider,
	fixtures: function(){
		mockServer.onFeathersService('messages', messageStore, {id: '_id'});
	}
});
Exemplo n.º 15
0
//added webcam
import Webcam from 'react-webcam';



const feathers = require('feathers/client');
const socketio = require('feathers-socketio/client');
const hooks = require('feathers-hooks');
const io = require('socket.io-client');

//klasse erstellen
const AddContentPage = React.createClass({
	handleSubmitAddContent() {

		const socket = io('http://localhost:3030');
		const app = feathers().configure(hooks()).configure(socketio(socket));

  		const learnpackagesService = app.service('learnpackages');
  		learnpackagesService.find({name: this.state.name}).then(function(learnpackages) {
  			
  		});
  		console.log(this.state.name);

  		learnpackagesService.create({email: this.state.email, age: this.state.age, password: this.state.password})
  					.then(function(result) {
  						//console.log("Added:" +email);
  					});

	},
	handleVocabelOneChange: function(e) {
    this.setState({vocOne: e.target.value});
Exemplo n.º 16
0
const feathers = require('feathers/client');
const socketio = require('feathers-socketio/client');
const io = require('socket.io-client');

const socketV1 = io('http://localhost:3030/api/v1/messages');
const socketV2 = io('http://localhost:3030/api/v2/messages');

const apiV1 = feathers().configure(socketio(socketV1));
const apiV2 = feathers().configure(socketio(socketV2));

// Get the message service that uses a websocket connection
const messageServiceV1 = apiV1.service('messages');
const messageServiceV2 = apiV2.service('messages');

messageServiceV1.on('created', message => console.log('Received a API V1 message', message));
messageServiceV2.on('created', message => console.log('Received a API V2 message', message));

console.log('Feathers client running');