diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000..053e8920fd --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +REACT_APP_IVLE_KEY=your_ivle_key_here diff --git a/README.md b/README.md index 50af05e024..f375a1c9d3 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ 1. Install a stable version of Yarn and NodeJS. 2. Run `yarn` to install dependencies. -3. Set the environment variable `REACT_APP_IVLE_KEY` to contain your IVLE Lapi - key. -4. Run desired script in `package.json`. `yarn start` starts the development - server. +3. Copy the `.env.example` file as `.env` and set the variable `REACT_APP_IVLE_KEY` + to contain your IVLE Lapi key. +4. Run `yarn start` to start the server at `localhost:80`. Admin permissions may + be required for your OS to serve at port 80. ## Application Structure diff --git a/package.json b/package.json index 20f22f6dc0..8e747ef961 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "@types/acorn": "^4.0.3", "@types/classnames": "^2.2.3", "@types/common-tags": "^1.4.0", + "@types/dotenv": "^4.0.3", "@types/enzyme": "^3.1.9", "@types/enzyme-adapter-react-16": "^1.0.2", "@types/estree": "^0.0.39", diff --git a/src/sagas/index.ts b/src/sagas/index.ts index e38010d9e9..1c17821887 100644 --- a/src/sagas/index.ts +++ b/src/sagas/index.ts @@ -17,7 +17,6 @@ function* mainSaga() { } function* interpreterSaga(): SagaIterator { - // let library = yield select((state: Shape) => state.config.library) let context: Context yield takeEvery(actionTypes.EVAL_EDITOR, function*() { @@ -53,7 +52,6 @@ function* loginSaga(): SagaIterator { const apiLogin = 'https://ivle.nus.edu.sg/api/login/' const key = IVLE_KEY const callback = `${window.location.protocol}//${window.location.hostname}/academy` - alert(`${apiLogin}?apikey=${key}&url=${callback}`) window.location.href = `${apiLogin}?apikey=${key}&url=${callback}` yield undefined }) diff --git a/src/utils/secrets.ts b/src/utils/secrets.ts index b9bebf763a..092f17fd5f 100644 --- a/src/utils/secrets.ts +++ b/src/utils/secrets.ts @@ -1 +1,5 @@ +import * as dotenv from 'dotenv' + +dotenv.config() + export const IVLE_KEY = process.env.REACT_APP_IVLE_KEY diff --git a/yarn.lock b/yarn.lock index 8700a4eb6d..c78e448df1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -214,6 +214,12 @@ version "2.0.0" resolved "https://registry.yarnpkg.com/@types/dom4/-/dom4-2.0.0.tgz#00dc42fed6b36a7a6dabb8f7a9c9e678ee644e05" +"@types/dotenv@^4.0.3": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@types/dotenv/-/dotenv-4.0.3.tgz#ebcfc40da7bc0728b705945b7db48485ec5b4b67" + dependencies: + "@types/node" "*" + "@types/enzyme-adapter-react-16@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@types/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.0.2.tgz#15ae37c64d6221a6f4b3a4aacc357cf773859de4"