Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import io from 'socket.io-client'
import feathers, { socketio, authentication } from '@feathersjs/client'
const socket = io(process.env.REACT_APP_API_SERVER, {
transports: ['websocket'],
forceNew: true,
})
const client = feathers()
client.configure(socketio(socket, { timeout: 10000 }))
client.configure(
authentication({
storage: window.localStorage,
entity: 'user',
service: 'users',
})
)
// Try to prevent login timeouts although I don't think it actually works
// TODO: investigate how to fix this
client.service('authentication').timeout = 20000
client.service('users').timeout = 20000
export const channels = client.service('api/channels')
export const posts = client.service('api/posts')
export function createBackendClient(): BackendClient {
const socket = io('http://localhost:8080', {
transports: ['websocket'],
});
const app = feathers();
app.configure(feathers.socketio(socket));
// TODO: Actually wrap client rather than just returning client
return app;
}
export function createServerClient(url): ServerClient {
const socket = io(url, {
transports: ['websocket'],
});
const app = feathers();
app.configure(
feathers.socketio(socket, {
// TODO: Definately shouldn't be this long
timeout: 60000,
}),
);
// TODO: Actually wrap client rather than just returning client
return { client: app, socket };
}
}
return Promise.resolve(context)
}],
},
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)
},
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
import io from 'socket.io-client';
import feathers from '@feathersjs/client';
const socket = io('http://localhost:3030');
const client = feathers();
client.configure(feathers.socketio(socket));
client.configure(feathers.authentication({
storage: window.localStorage
}));
export default client;
opts._t === '/m/') {
evbus.trigger('update:' + opts._id, context.result.data);
}
return Promise.resolve(context);
}],
},
};
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;
if (typeof opts === 'object' &&
opts._t === '/m/') {
evbus.trigger('update:' + opts._id, context.result.data);
}
return Promise.resolve(context);
}],
},
};
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;