From 46fe5504faf79e8dc083bc1458fbbeee7b9bc24e Mon Sep 17 00:00:00 2001 From: thianlopezz Date: Fri, 9 Nov 2018 23:23:54 -0500 Subject: [PATCH 1/2] Express integration for serving page --- .gitignore | 3 +++ index.js | 18 ++++++++++++++++++ package.json | 22 ++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14c4b9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +npm-debug.log +node_modules +package-lock.json \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..e976e8e --- /dev/null +++ b/index.js @@ -0,0 +1,18 @@ +const express = require('express'); +const path = require('path'); +const http = require('http'); + +const app = express(); + +app.use(express.static(path.join(__dirname, '/public'))); + +app.get('*', (req, res) => { + res.sendFile(path.join(__dirname, '/public/index.html')); +}); + +const port = '7001'; +app.set('port', port); + +const server = http.createServer(app); + +server.listen(port, () => console.log(`Magic Happens on port:${port}`)); diff --git a/package.json b/package.json new file mode 100644 index 0000000..16ffd61 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "client-quickstart", + "version": "1.0.0", + "description": "\r \"Twilio\"\r ", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/thianlopezz/client-quickstart-js.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/thianlopezz/client-quickstart-js/issues" + }, + "homepage": "https://github.com/thianlopezz/client-quickstart-js#readme", + "dependencies": { + "express": "^4.16.4" + } +} From f49eba9ce5e6bfc52f6045a2db8b8f853d06c852 Mon Sep 17 00:00:00 2001 From: thianlopezz Date: Fri, 9 Nov 2018 23:33:13 -0500 Subject: [PATCH 2/2] Readme and package.js info corrections --- README.md | 13 +++++-------- package.json | 6 +++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 65b146a..929b71b 100644 --- a/README.md +++ b/README.md @@ -41,23 +41,20 @@ NOTE: You should not use Twilio Functions to generate capability tokens for your [Visit our guide](https://www.twilio.com/docs/voice/client/capability-tokens) to learn how to generate capability tokens in your own C#, Java, Node.js, PHP, Python, or Ruby application. -## Setting up a local HTTP server +## Running the app -You'll need to load the front end of your web application from a web server for Twilio Client to connect successfully from Chrome (it should work in Firefox if you load it from the file system). The easiest way to do that is to install a local HTTP server like [http-server](https://github.com/indexzero/http-server) +It only left to run our application ```bash -npm install http-server -g +npm install ``` -or +and ```bash -sudo npm install http-server -g +node index.js ``` -on macOS or Linux - - ## Run the local server ```bash diff --git a/package.json b/package.json index 16ffd61..6c0ec99 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,12 @@ "type": "git", "url": "git+https://github.com/thianlopezz/client-quickstart-js.git" }, - "author": "", + "author": "TwilioDevEd", "license": "ISC", "bugs": { - "url": "https://github.com/thianlopezz/client-quickstart-js/issues" + "url": "https://github.com/TwilioDevEd/client-quickstart-js/issues" }, - "homepage": "https://github.com/thianlopezz/client-quickstart-js#readme", + "homepage": "https://github.com/TwilioDevEd/client-quickstart-js#readme", "dependencies": { "express": "^4.16.4" }