Setup Circle CI, add brakeman config (#13)

* Add circle ci config

* Change config to fix tests

* Update config

* Fix eslint command, add brakeman
This commit is contained in:
Pranav Raj S
2019-08-21 12:59:56 +05:30
committed by GitHub
parent 6e4fec2b55
commit 2c144d5ad3
39 changed files with 847 additions and 616 deletions
+6 -7
View File
@@ -3,17 +3,14 @@ import constants from '../constants';
import Auth from '../api/auth';
import router from '../routes';
const parseErrorCode = (error) => {
const parseErrorCode = error => {
if (error.response) {
if (error.response.status === 401) {
// If auth failed
} else if (error.response.status === 500) {
// If server failed
} else if (error.response.status === 422) {
// If request params are errored
} else if (error.response.status === 901 || error.response.status === 902) {
let name = 'billing_deactivated';
if (Auth.isAdmin()) {
@@ -26,13 +23,12 @@ const parseErrorCode = (error) => {
}
} else {
// Something happened in setting up the request that triggered an Error
}
// Do something with request error
return Promise.reject(error);
};
export default (axios) => {
export default axios => {
const wootApi = axios.create();
wootApi.defaults.baseURL = constants.apiURL;
// Add Auth Headers to requests if logged in
@@ -40,6 +36,9 @@ export default (axios) => {
Object.assign(wootApi.defaults.headers.common, Auth.getAuthData());
}
// Response parsing interceptor
wootApi.interceptors.response.use(response => response, error => parseErrorCode(error));
wootApi.interceptors.response.use(
response => response,
error => parseErrorCode(error)
);
return wootApi;
};
+11 -10
View File
@@ -1,6 +1,5 @@
/* eslint-env browser */
/* eslint no-console: 0 */
/* global location */
import Pusher from 'pusher-js';
import AuthAPI from '../api/auth';
import CONSTANTS from '../constants';
@@ -8,7 +7,6 @@ import CONSTANTS from '../constants';
const ding = require('../assets/audio/ding.mp3');
class VuePusher {
constructor(apiKey, options) {
this.app = options.app;
this.pusher = new Pusher(apiKey, options);
@@ -28,7 +26,7 @@ class VuePusher {
}
bindEvent(channel) {
channel.bind('message.created', (data) => {
channel.bind('message.created', data => {
// Play sound if incoming
if (!data.message_type) {
new Audio(ding).play();
@@ -36,15 +34,15 @@ class VuePusher {
this.app.$store.dispatch('addMessage', data);
});
channel.bind('conversation.created', (data) => {
channel.bind('conversation.created', data => {
this.app.$store.dispatch('addConversation', data);
});
channel.bind('status_change:conversation', (data) => {
channel.bind('status_change:conversation', data => {
this.app.$store.dispatch('addConversation', data);
});
channel.bind('assignee.changed', (payload) => {
channel.bind('assignee.changed', payload => {
if (!payload.meta) return;
const { assignee } = payload.meta;
const { id } = payload;
@@ -61,19 +59,22 @@ class VuePusher {
});
channel.bind('page:reload', () => {
location.reload();
window.location.reload();
});
}
}
/* eslint no-param-reassign: ["error", { "props": false }]*/
/* eslint no-param-reassign: ["error", { "props": false }] */
export default {
init() {
// Log only if env is testing or development.
Pusher.logToConsole = CONSTANTS.PUSHER.logToConsole;
// Init Pusher
const options = { encrypted: true, app: window.WOOT, cluster: CONSTANTS.PUSHER.cluster };
const options = {
encrypted: true,
app: window.WOOT,
cluster: CONSTANTS.PUSHER.cluster,
};
const pusher = new VuePusher(CONSTANTS.PUSHER.token, options);
// Add to global Obj
if (AuthAPI.isLoggedIn()) {
+1 -1
View File
@@ -1,6 +1,6 @@
/* eslint no-console: 0 */
/* eslint no-param-reassign: 0 */
export default (Vuex) => {
export default Vuex => {
const wootState = new Vuex.Store({
state: {
authenticated: false,