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/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/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..6c0ec99 --- /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": "TwilioDevEd", + "license": "ISC", + "bugs": { + "url": "https://github.com/TwilioDevEd/client-quickstart-js/issues" + }, + "homepage": "https://github.com/TwilioDevEd/client-quickstart-js#readme", + "dependencies": { + "express": "^4.16.4" + } +}