diff --git a/app/api/FileAPI.jsx b/app/api/FileAPI.jsx index 0393fdd..f1e8d0e 100644 --- a/app/api/FileAPI.jsx +++ b/app/api/FileAPI.jsx @@ -1,5 +1,5 @@ // - Import react component -import { storageRef } from 'app/firebase/' +import { storageRef } from 'app/firebaseClient/' //- Import actions diff --git a/app/api/StringAPI.jsx b/app/api/StringAPI.jsx index 343f597..0a2667d 100644 --- a/app/api/StringAPI.jsx +++ b/app/api/StringAPI.jsx @@ -1,5 +1,5 @@ // - Import react component -import { storageRef } from 'app/firebase/' +import { storageRef } from 'app/firebaseClient/' //- Import actions diff --git a/app/components/Master/Master.tsx b/app/components/Master/Master.tsx index fb794e5..26227c6 100644 --- a/app/components/Master/Master.tsx +++ b/app/components/Master/Master.tsx @@ -3,7 +3,7 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import { Route, Switch, NavLink, withRouter, Redirect } from 'react-router-dom' -import { firebaseAuth, firebaseRef } from 'app/firebase' +import { firebaseAuth, firebaseRef } from 'app/firebaseClient' import { push } from 'react-router-redux' import Snackbar from 'material-ui/Snackbar' import LinearProgress from 'material-ui/LinearProgress' diff --git a/app/factories/serviceProvide.ts b/app/factories/serviceProvide.ts index ba8ccc4..59222ae 100644 --- a/app/factories/serviceProvide.ts +++ b/app/factories/serviceProvide.ts @@ -16,15 +16,17 @@ import { IVoteService } from 'services/votes' //#region Service implemented classes // - Firebase services -import { AuthorizeService } from 'firebase/services/authorize' -import { CircleService } from 'firebase/services/circles' -import { CommentService } from 'firebase/services/comments' -import { CommonService } from 'firebase/services/common' -import { ImageGalleryService } from 'firebase/services/imageGallery' -import { NotificationService } from 'firebase/services/notifications' -import { PostService } from 'firebase/services/posts' -import { UserService } from 'firebase/services/users' -import { VoteService } from 'firebase/services/votes' +import { + AuthorizeService, + CircleService, + CommentService, + CommonService, + ImageGalleryService, + NotificationService, + PostService, + UserService, + VoteService +} from 'firebaseClient/services' //#endregion diff --git a/app/firebase/index.js b/app/firebase/index.js deleted file mode 100644 index e9fda77..0000000 --- a/app/firebase/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import firebase from 'firebase' - -try { - let config = { - apiKey: process.env.API_KEY, - authDomain: process.env.AUTH_DOMAIN, - databaseURL: process.env.DATABASE_URL, - projectId: process.env.PROJECT_ID, - storageBucket: process.env.STORAGE_BUCKET, - messagingSenderId: process.env.MESSAGING_SENDER_ID - } - - firebase.initializeApp(config) -} catch (e) { - -} - -// - Storage reference -export let storageRef = firebase.storage().ref() - -// - Database authorize -export let firebaseAuth = firebase.auth -export let firebaseRef = firebase.database().ref() - -// - Firebase default -export default firebase diff --git a/app/firebase/services/authorize/AuthorizeService.ts b/app/firebase/services/authorize/AuthorizeService.ts deleted file mode 100644 index 194eae3..0000000 --- a/app/firebase/services/authorize/AuthorizeService.ts +++ /dev/null @@ -1,106 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { IAuthorizeService } from 'services/authorize' -import { User } from 'Domain/users' -import { LoginUser, RegisterUserResult } from 'domain/authorize' -import { SocialError } from 'domain/common' - -/** - * Firbase authorize service - * - * @export - * @class AuthorizeService - * @implements {IAuthorizeService} - */ -export class AuthorizeService implements IAuthorizeService { - - /** - * Login the user - * - * @returns {Promise} - * @memberof IAuthorizeService - */ - public login: (email: string, password: string) => Promise = (email, password) => { - - return new Promise((resolve, reject) => { - firebaseAuth() - .signInWithEmailAndPassword(email, password) - .then((result) => { - resolve(new LoginUser(result.uid)) - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - }) - } - - /** - * Logs out the user - * - * @returns {Promise} - * @memberof IAuthorizeService - */ - public logout: () => Promise = () => { - return new Promise((resolve, reject) => { - firebaseAuth() - .signOut() - .then((result) => { - resolve() - }) - .catch((error: any) => { - - reject(new SocialError(error.code, error.message)) - }) - }) - } - - /** - * Register a user - * - * @returns {Promise} - * @memberof IAuthorizeService - */ - public registerUser: (user: User) => Promise = (user) => { - return new Promise((resolve, reject) => { - firebaseAuth() - .createUserWithEmailAndPassword(user.email as string, user.password as string) - .then((signupResult) => { - firebaseRef.child(`users/${signupResult.uid}/info`) - .set({ - ...user, - avatar: 'noImage' - }) - .then((result) => { - resolve(new RegisterUserResult(signupResult.uid)) - }) - .catch((error: any) => reject(new SocialError(error.name, error.message))) - }) - .catch((error: any) => reject(new SocialError(error.code, error.message))) - }) - } - - /** - * Update user password - * - * @returns {Promise} - * @memberof IAuthorizeService - */ - public updatePassword: (newPassword: string) => Promise = (newPassword) => { - - return new Promise((resolve, reject) => { - let user = firebaseAuth().currentUser - if (user) { - user.updatePassword(newPassword).then(() => { - // Update successful. - resolve() - }).catch((error: any) => { - // An error happened. - reject(new SocialError(error.code, error.message)) - }) - } - - }) - } - -} diff --git a/app/firebase/services/authorize/index.ts b/app/firebase/services/authorize/index.ts deleted file mode 100644 index 3378979..0000000 --- a/app/firebase/services/authorize/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { AuthorizeService } from './AuthorizeService' - -export { - AuthorizeService -} diff --git a/app/firebase/services/circles/CircleService.ts b/app/firebase/services/circles/CircleService.ts deleted file mode 100644 index fb32162..0000000 --- a/app/firebase/services/circles/CircleService.ts +++ /dev/null @@ -1,120 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { ICircleService } from 'services/circles' -import { Circle, UserFollower } from 'domain/circles' -import { User } from 'domain/users' - -/** - * Firbase circle service - * - * @export - * @class CircleService - * @implements {ICircleService} - */ -export class CircleService implements ICircleService { - - public addCircle: (userId: string, circle: Circle) - => Promise = (userId, circle) => { - return new Promise((resolve,reject) => { - let circleRef = firebaseRef.child(`userCircles/${userId}/circles`).push(circle) - circleRef.then(() => { - resolve(circleRef.key as string) - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - - } - - public addFollowingUser: (userId: string, circleId: string, userCircle: User, userFollower: UserFollower, userFollowingId: string) - => Promise = (userId, circleId, userCircle, userFollower, userFollowingId) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`userCircles/${userId}/circles/${circleId}/users/${userFollowingId}`] = userCircle - updates[`userCircles/${userFollowingId}/circles/-Followers/users/${userId}`] = userFollower - - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - public deleteFollowingUser: (userId: string, circleId: string, userFollowingId: string) - => Promise = (userId, circleId, userFollowingId) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`userCircles/${userId}/circles/${circleId}/users/${userFollowingId}`] = null - updates[`userCircles/${userFollowingId}/circles/-Followers/users/${userId}`] = null - - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - public updateCircle: (userId: string, circleId: string, circle: Circle) - => Promise = (userId, circleId, circle) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`userCircles/${userId}/circles/${circleId}`] = circle - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - - public deleteCircle: (userId: string, circleId: string) - => Promise = (userId, circleId) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`userCircles/${userId}/circles/${circleId}`] = null - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - public getCircles: (userId: string) => Promise<{ [circleId: string]: Circle }> = (userId) => { - return new Promise<{ [circleId: string]: Circle }>((resolve,reject) => { - let circlesRef: any = firebaseRef.child(`userCircles/${userId}/circles`) - - circlesRef.once('value').then((snapshot: any) => { - let circles: any = snapshot.val() || {} - let parsedCircles: { [circleId: string]: Circle } = {} - Object.keys(circles).forEach((circleId) => { - - parsedCircles[circleId] = { - id: circleId, - ...circles[circleId] - } - }) - resolve(parsedCircles) - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } -} diff --git a/app/firebase/services/circles/index.ts b/app/firebase/services/circles/index.ts deleted file mode 100644 index e907c11..0000000 --- a/app/firebase/services/circles/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { CircleService } from './CircleService' - -export { - CircleService -} diff --git a/app/firebase/services/comments/CommentService.ts b/app/firebase/services/comments/CommentService.ts deleted file mode 100644 index 3f4be50..0000000 --- a/app/firebase/services/comments/CommentService.ts +++ /dev/null @@ -1,71 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { ICommentService } from 'services/comments' -import { Comment } from 'domain/comments' - -/** - * Firbase comment service - * - * @export - * @class CommentService - * @implements {ICommentService} - */ -export class CommentService implements ICommentService { - public addComment: (postId: string, comment: Comment) - => Promise = (postId, comment) => { - return new Promise((resolve,reject) => { - let commentRef: any = firebaseRef.child(`postComments/${postId}`).push(comment) - commentRef.then(() => { - resolve(commentRef.key) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public getComments: () - => Promise<{ [postId: string]: { [commentId: string]: Comment } }> = () => { - return new Promise<{ [postId: string]: { [commentId: string]: Comment }}>((resolve,reject) => { - let commentsRef: any = firebaseRef.child(`postComments`) - commentsRef.on('value', (snapshot: any) => { - let comments: {[postId: string]: {[commentId: string]: Comment}} = snapshot!.val() || {} - resolve(comments) - }) - }) - } - - public updateComment: (userId: string, postId: string, comment: Comment) - => Promise = (userId, postId, comment) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`postComments/${postId}/${userId}`] = comment - firebaseRef.update(updates) - .then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public deleteComment: (commentId: string, postId: string) - => Promise = (commentId, postId) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`postComments/${postId}/${commentId}`] = null - firebaseRef.update(updates) - .then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } -} diff --git a/app/firebase/services/comments/index.ts b/app/firebase/services/comments/index.ts deleted file mode 100644 index e4f9a1e..0000000 --- a/app/firebase/services/comments/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { CommentService } from './CommentService' - -export { - CommentService -} \ No newline at end of file diff --git a/app/firebase/services/common/CommonService.ts b/app/firebase/services/common/CommonService.ts deleted file mode 100644 index ebe4cee..0000000 --- a/app/firebase/services/common/CommonService.ts +++ /dev/null @@ -1,17 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { ICommonService } from 'services/common' - -/** - * Firbase common service - * - * @export - * @class CommonService - * @implements {ICommonService} - */ -export class CommonService implements ICommonService { - - -} \ No newline at end of file diff --git a/app/firebase/services/common/index.ts b/app/firebase/services/common/index.ts deleted file mode 100644 index 7470140..0000000 --- a/app/firebase/services/common/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { CommonService } from './CommonService' - -export { - CommonService -} \ No newline at end of file diff --git a/app/firebase/services/imageGallery/ImageGalleryService.ts b/app/firebase/services/imageGallery/ImageGalleryService.ts deleted file mode 100644 index fd30865..0000000 --- a/app/firebase/services/imageGallery/ImageGalleryService.ts +++ /dev/null @@ -1,110 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth, storageRef } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { IImageGalleryService } from 'services/imageGallery' -import { Image } from 'domain/imageGallery' - -/** - * Firbase image gallery service - * - * @export - * @class ImageGalleryService - * @implements {IImageGalleryService} - */ -export class ImageGalleryService implements IImageGalleryService { - - public getImageGallery: (userId: string) - => Promise = (userId) => { - return new Promise((resolve,reject) => { - let imagesRef: any = firebaseRef.child(`userFiles/${userId}/files/images`) - - imagesRef.once('value').then((snapshot: any) => { - let images = snapshot.val() || {} - let parsedImages: Image[] = [] - Object.keys(images).forEach((imageId) => { - parsedImages.push({ - id: imageId, - ...images[imageId] - }) - }) - resolve(parsedImages) - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - - public saveImage: (userId: string, image: Image) - => Promise = (userId, image) => { - return new Promise((resolve,reject) => { - - let imageRef = firebaseRef.child(`userFiles/${userId}/files/images`).push(image) - imageRef.then(() => { - resolve(imageRef.key!) - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - - public deleteImage: (userId: string, imageId: string) - => Promise = (userId, imageId) => { - return new Promise((resolve,reject) => { - - let updates: any = {} - updates[`userFiles/${userId}/files/images/${imageId}`] = null - - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - - }) - } - - public uploadImage: (file: any, fileName: string, progressCallback: Function) - => Promise = (file, fileName, progressCallback) => { - return new Promise((resolve,reject) => { - - let storegeFile: any = storageRef.child(`images/${fileName}`) - - // Upload file - let task: any = storegeFile.put(file) - - // Upload storage bar - task.on('state_changed', (snapshot: any) => { - let percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100 - progressCallback(percentage) - - }, (error: any) => { - reject(new SocialError(error.code, error.message)) - }, () => { - resolve() - }) - }) - } - - public downloadImage: (fileName: string) - => Promise = (fileName) => { - return new Promise((resolve,reject) => { - - // Create a reference to the file we want to download - let starsRef: any = storageRef.child(`images/${fileName}`) - - // Get the download URL - starsRef.getDownloadURL().then((url: string) => { - resolve(url) - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - }) - } -} diff --git a/app/firebase/services/imageGallery/index.ts b/app/firebase/services/imageGallery/index.ts deleted file mode 100644 index 787b63d..0000000 --- a/app/firebase/services/imageGallery/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ImageGalleryService } from './ImageGalleryService' - -export { - ImageGalleryService -} \ No newline at end of file diff --git a/app/firebase/services/notifications/index.ts b/app/firebase/services/notifications/index.ts deleted file mode 100644 index 943f9ef..0000000 --- a/app/firebase/services/notifications/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { NotificationService } from './NotificationService' - -export { - NotificationService -} \ No newline at end of file diff --git a/app/firebase/services/notifications/notificationService.ts b/app/firebase/services/notifications/notificationService.ts deleted file mode 100644 index 22f946d..0000000 --- a/app/firebase/services/notifications/notificationService.ts +++ /dev/null @@ -1,72 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { Notification } from 'domain/notifications' -import { INotificationService } from 'services/notifications' - -/** - * Firbase notification service - * - * @export - * @class NotificationService - * @implements {INotificationService} - */ -export class NotificationService implements INotificationService { - - public addNotification: (notification: Notification) - => Promise = (notification: Notification) => { - return new Promise((resolve,reject) => { - firebaseRef.child(`userNotifies/${notification.notifyRecieverUserId}`) - .push(notification) - .then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - }) - } - - public getNotifications: (userId: string) - => Promise<{ [notifyId: string]: Notification }> = (userId) => { - return new Promise<{ [notifyId: string]: Notification }>((resolve,reject) => { - let notifiesRef: any = firebaseRef.child(`userNotifies/${userId}`) - notifiesRef.on('value', (snapshot: any) => { - let notifies: {[notifyId: string]: Notification} = snapshot.val() || {} - resolve(notifies) - }) - }) - } - - public deleteNotification: (notificationId: string, userId: string) - => Promise = (notificationId, userId) => { - return new Promise((resolve, reject) => { - let updates: any = {} - updates[`userNotifies/${userId}/${notificationId}`] = null - firebaseRef.update(updates) - .then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - }) - } - - public setSeenNotification: (notificationId: string, userId: string, notification: Notification) - => Promise = (notificationId, userId, notification) => { - return new Promise((resolve, reject) => { - let updates: any = {} - updates[`userNotifies/${userId}/${notificationId}`] = notification - firebaseRef.update(updates) - .then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code, error.message)) - }) - }) - } - -} diff --git a/app/firebase/services/posts/PostService.ts b/app/firebase/services/posts/PostService.ts deleted file mode 100644 index c731fb9..0000000 --- a/app/firebase/services/posts/PostService.ts +++ /dev/null @@ -1,101 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { Post } from 'domain/posts' -import { IPostService } from 'services/posts' - -/** - * Firbase post service - * - * @export - * @class PostService - * @implements {IPostService} - */ -export class PostService implements IPostService { - - public addPost: (userId: string, post: Post) - => Promise = (userId, post) => { - return new Promise((resolve,reject) => { - let postRef: any = firebaseRef.child(`userPosts/${userId}/posts`).push(post) - postRef.then(() => { - resolve(postRef.key) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public updatePost: (userId: string, postId: string, post: Post) - => Promise = (userId, postId, post) => { - return new Promise((resolve,reject) => { - let updates: any = {} - updates[`userPosts/${userId}/posts/${postId}`] = post - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public deletePost: (userId: string, postId: string) - => Promise = (userId, postId) => { - return new Promise((resolve,reject) => { - let updates: any = {} - updates[`userPosts/${userId}/posts/${postId}`] = null - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public getPosts: (userId: string) - => Promise<{ [postId: string]: Post }> = (userId) => { - return new Promise<{ [postId: string]: Post }>((resolve,reject) => { - - let postsRef: any = firebaseRef.child(`userPosts/${userId}/posts`) - postsRef.once('value').then((snapshot: any) => { - let posts: any = snapshot.val() || {} - let parsedPosts: { [postId: string]: Post } = {} - - Object.keys(posts).forEach((postId) => { - parsedPosts[postId] = { - id: postId, - ...posts[postId] - } - }) - resolve(parsedPosts) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public getPostById: (userId: string, postId: string) - => Promise = (userId, postId) => { - return new Promise((resolve,reject) => { - - let postsRef: any = firebaseRef.child(`userPosts/${userId}/posts/${postId}`) - - postsRef.once('value').then((snapshot: any) => { - let newPost = snapshot.val() || {} - let post: Post = { - id: postId, - ...newPost - } - resolve(post) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - - }) - } -} diff --git a/app/firebase/services/posts/index.ts b/app/firebase/services/posts/index.ts deleted file mode 100644 index e9c7fd6..0000000 --- a/app/firebase/services/posts/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { PostService } from './PostService' - -export { - PostService -} \ No newline at end of file diff --git a/app/firebase/services/users/UserService.ts b/app/firebase/services/users/UserService.ts deleted file mode 100644 index e98fad7..0000000 --- a/app/firebase/services/users/UserService.ts +++ /dev/null @@ -1,73 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { Profile } from 'domain/users' -import { IUserService } from 'services/users' - -/** - * Firbase user service - * - * @export - * @class UserService - * @implements {IUserService} - */ -export class UserService implements IUserService { - public getUserProfile: (userId: string) - => Promise = (userId) => { - return new Promise((resolve,reject) => { - let userProfileRef: any = firebaseRef.child(`users/${userId}/info`) - - userProfileRef.once('value').then((snapshot: any) => { - let userProfile: Profile = snapshot.val() || {} - resolve(userProfile) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - - public updateUserProfile: (userId: string, profile: Profile) - => Promise = (userId, profile) => { - return new Promise((resolve,reject) => { - let updates: any = {} - - updates[`users/${userId}/info`] = profile - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - public getUsersProfile: (userId: string) - => Promise<{ [userId: string]: Profile }> = (userId) => { - return new Promise<{ [userId: string]: Profile }>((resolve,reject) => { - let usersProfileRef: any = firebaseRef.child(`users`) - - usersProfileRef.once('value').then((snapshot: any) => { - let usersProfile: any = snapshot.val() || {} - let parsedusersProfile: {[userId: string]: Profile} = {} - Object.keys(usersProfile).forEach((userKey) => { - if (userId !== userKey) { - let userInfo = usersProfile[userKey].info - parsedusersProfile[userKey] = { - avatar: userInfo.avatar, - email: userInfo.email, - fullName: userInfo.fullName, - banner: userInfo.banner, - tagLine: userInfo.tagLine - } - } - }) - resolve(parsedusersProfile) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - -} diff --git a/app/firebase/services/users/index.ts b/app/firebase/services/users/index.ts deleted file mode 100644 index d883994..0000000 --- a/app/firebase/services/users/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { UserService } from './UserService' - -export { - UserService -} \ No newline at end of file diff --git a/app/firebase/services/votes/VoteService.ts b/app/firebase/services/votes/VoteService.ts deleted file mode 100644 index 9e88727..0000000 --- a/app/firebase/services/votes/VoteService.ts +++ /dev/null @@ -1,57 +0,0 @@ -// - Import react components -import { firebaseRef, firebaseAuth } from 'app/firebase/' - -import { SocialError } from 'domain/common' -import { Vote } from 'domain/votes' -import { IVoteService } from 'services/votes' - -/** - * Firbase vote service - * - * @export - * @class VoteService - * @implements {IVoteService} - */ -export class VoteService implements IVoteService { - - public addVote: (vote: Vote) - => Promise = (vote) => { - return new Promise((resolve,reject) => { - let voteRef = firebaseRef.child(`postVotes/${vote.postId}`) - .push(vote) - voteRef.then(() => { - resolve(voteRef.key!) - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - public getVotes: () - => Promise<{ [postId: string]: { [voteId: string]: Vote } }> = () => { - return new Promise<{ [postId: string]: { [voteId: string]: Vote } }>((resolve,reject) => { - let votesRef: any = firebaseRef.child(`postVotes`) - - votesRef.on('value',(snapshot: any) => { - let postVotes: {[postId: string]: {[voteId: string]: Vote}} = snapshot.val() || {} - resolve(postVotes) - }) - - }) - } - - public deleteVote: (voteId: string, postId: string) - => Promise = (voteId, postId) => { - return new Promise((resolve,reject) => { - let updates: any = {} - updates[`postVotes/${postId}/${voteId}`] = null - firebaseRef.update(updates).then(() => { - resolve() - }) - .catch((error: any) => { - reject(new SocialError(error.code,error.message)) - }) - }) - } - -} diff --git a/app/firebase/services/votes/index.ts b/app/firebase/services/votes/index.ts deleted file mode 100644 index 8859aa9..0000000 --- a/app/firebase/services/votes/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { VoteService } from './VoteService' - -export { - VoteService -} diff --git a/app/tests/actions/authorizeActions.test.jsx b/app/tests/actions/authorizeActions.test.jsx index 44d392a..23f9dd8 100644 --- a/app/tests/actions/authorizeActions.test.jsx +++ b/app/tests/actions/authorizeActions.test.jsx @@ -3,7 +3,7 @@ import configureMockStore from 'redux-mock-store' import thunk from 'redux-thunk' let expect = require('expect') -import firebase, {firebaseRef} from 'app/firebase' +import firebase, {firebaseRef} from 'app/firebaseClient' let authorizeActions = require('authorizeActions') import * as types from 'actionTypes' diff --git a/package.json b/package.json index e17ebd8..6a7dc68 100644 --- a/package.json +++ b/package.json @@ -71,11 +71,12 @@ "babel-core": "^6.24.1", "babel-loader": "^7.1.2", "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-polyfill": "^6.26.0", + "babel-polyfill": "^6.26.0", "babel-preset-env": "^1.6.0", "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", "css-loader": "^0.28.7", + "eslint": "^4.9.0", "karma": "^1.6.0", "karma-chrome-launcher": "^2.0.0", "karma-mocha": "^1.3.0", diff --git a/webpack.config.js b/webpack.config.js index 1d29521..88df85f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -87,7 +87,7 @@ module.exports = { constants: 'app/constants', services: 'app/services', factories: 'app/factories', - 'firebase/services': 'app/firebase/services', + 'firebaseClient/services': 'app/firebaseClient/services', domain: 'app/domain', api: 'app/api', db: 'app/db',