Skip to content

Instantly share code, notes, and snippets.

@jermsam
Last active May 1, 2019 14:28
Show Gist options
  • Save jermsam/e15ada2df9bc296855ebb72546d9f66e to your computer and use it in GitHub Desktop.
Save jermsam/e15ada2df9bc296855ebb72546d9f66e to your computer and use it in GitHub Desktop.
anything wrong?
/* eslint-disable no-console */
import feathers from '@feathersjs/client';
import io from 'socket.io-client';
// require('dotenv').config();
const url =
process.env.NODE_ENV === 'production'
? 'https://tvillage-s.herokuapp.com'
: 'http://localhost:3030';
// console.log(process.env.NODE_ENV);
// Socket.io is exposed as the `io` global.
const socket = io(url, {
transports: ['websocket'],
forceNew: true
});
// @feathersjs/client is exposed as the `feathers` global.
const app = feathers();
// Connect to a different URL
const socketsClient = feathers.socketio(socket, {
timeout: 100000
});
// Configure socket client
app.configure(socketsClient);
// incase we later have to do authentication
if (process.browser) {
app.configure(
feathers.authentication({
storage: window.localStorage
// timeout: 20000
})
);
}
const sendToken = (action, value) =>
app.service('authManagement').create({ action, value }, {});
const bucket = process.env.AWS_BUCKET;
const checkIfVerified = async id => {
if (id) {
const { email, isVerified } = await app.service('users').get(id);
return { email, isVerified };
}
return null;
};
const getResetUserData = async (id, token, email) => {
if (id && token) {
const res = await app.service('users').get(id);
return {
data: {
email: res.email,
id,
token
}
};
}
return {
data: {
email,
id,
token
}
};
};
const signin = (data) =>console.log('signin with: ',data)
const getUser = userId => app.service('users').get(userId);
export {
app,
url,
bucket,
sendToken,
checkIfVerified,
getResetUserData,
getUser,
signin
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment