Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Next gen #4

Merged
merged 2 commits into from
May 3, 2017
Merged

Next gen #4

merged 2 commits into from
May 3, 2017

Conversation

juancarlospaco
Copy link

  • Changes to make twilio-chat work with next-gen libs.
    ⊂(ʘ‿ʘ)つ

Copy link

@hortega hortega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Just a few changes, please look at the comments.

.travis.yml Outdated
- export TWILIO_API_KEY=Your-Twilio-API-KEY
- export TWILIO_API_SECRET=Your-Twilio-API-SECRET
- export TWILIO_IPM_SERVICE_SID=Your-Twilio-IPM-SERVICE-SID
- NODE_TLS_REJECT_UNAUTHORIZED=0
Copy link

@hortega hortega Nov 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not really necessary and makes the code quite unsafe. You can read about it here nodejs/node#5258 (comment)

.travis.yml Outdated
- TWILIO_IPM_SERVICE_SID=Your-Twilio-IPM-SERVICE-SID

cache:
apt: true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem we are installing anything with apt, what is the purpose of this line?

@@ -56,6 +59,7 @@ a service like [ngrok](https://ngrok.com/).
$ ngrok http 3000
```


## Run the tests

1. Run backend tests
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a suggestion, you could change mocha test for npm test and also in package.json prevent the environment variable from being exported to console session and remove the && operator, as it's not necessary.

app.js Outdated
@@ -16,10 +16,10 @@ app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 18 and 19 can be deleted as most likely they won't be used and if they are needed, they can be recovered from history

routes/token.js Outdated
@@ -2,7 +2,8 @@ var express = require('express');
var router = express.Router();
var TokenService = require('../services/tokenService');

// POST /token/generate

// POST /token
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for fixing the comment

test/token.js Outdated
describe('token', function () {
describe('POST /token', function () {
it('generates a token', function (done) {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could remove this extra line

package.json Outdated
@@ -4,7 +4,7 @@
"private": "private",
"scripts": {
"start": "node ./bin/www",
"test": "export NODE_ENV=test && mocha test"
"test": "NODE_ENV=test npm test"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this line you define what the command npm test do. If you write here npm test you are creating a loop and that's why your build is broken. Please replace back with mocha

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additinally, you should rely on the mocha version installed for this project, concretely in ./node_modules/mocha/bin/mocha test.

There is another subtle problem. You are relying on dotenv-safe, which means that you don't have any step where you instruct the user to export the required env variables.

To fix this problem you have to explicitly export the env vars in the test script.

"test": "NODE_ENV=test TWILIO_ACCOUNT_SID=ACXXXXXXX ...."

For referencing mocha please use ./node_modules/.bin/mocha.

package.json Outdated
@@ -3,8 +3,8 @@
"version": "1.0.0",
"private": "private",
"scripts": {
"start": "node ./bin/www",
"test": "NODE_ENV=test npm test"
"start": "npm start",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this change? It was fine before, but now you are referencing npm start from npm start, creating an endless loop

@hortega
Copy link

hortega commented Nov 21, 2016

thanks @juancarlospaco ! Looks good to me

package.json Outdated
"moment": "^2.11.1",
"morgan": "~1.7.0",
"serve-favicon": "~2.3.2",
"twilio": "3.0.0-rc.16"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add ~ in front on the version so that it's not locked to this RC.

@smendes smendes merged commit 3aa0cbc into master May 3, 2017
@smendes smendes deleted the next-gen branch May 3, 2017 23:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants