Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt at config #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions client/chrome-extension/src/Config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const CONFIG = {
dev: { url: 'ws://localhost:4000/socket' },
prod: { url: 'wss://echo.websocket.org' }
}

class Config {
constructor(env) {
console.debug(`Constructing Config: ${env}`)
this.url = CONFIG.dev.url;

if (env == 'prod') {
this.url = CONFIG.prod.url
}
}
}

export default Config;
7 changes: 6 additions & 1 deletion client/chrome-extension/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import Client from './client/Client';
import AppController from './background/AppController';
import Config from './Config';

/**
* Set up parameters to AppController based on environment
* Here environment is chrome extension and messaging needs to be plumbed a certain way
*/
const client = new Client('ws://localhost:4000/socket', 'user'); // TODO use real values for address and username

const config = new Config('dev');
console.debug(`Background connecting to: ${config.url}`);

const client = new Client(config.url, 'user'); // TODO use real values for address and username
const sendMessage = (message) => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs[0]) {
Expand Down