Skip to content

Commit

Permalink
complete overhaul opening local app to SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerferrara committed Jan 12, 2019
1 parent d902230 commit 1c6333c
Show file tree
Hide file tree
Showing 9 changed files with 3,806 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Messenger-Bot
Simple Facebook messenger bot

For development:

1. Run the local dev server
npm run dev
2. Connect to Serveo
ssh -R apollo:80:localhost:1337 serveo.net
this directs all trafic from this public SSL domain to the local server. NOTE: https://apollo.serveo.net is the domain.
21 changes: 17 additions & 4 deletions index.js → index0.0.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@ const
express = require('express'),
bodyParser = require('body-parser'),
path = require('path'),
http = require('http'),
request = require('request'),
app = express().use(bodyParser.json()); // creates express http server

// PORT
let PORT = (process.env.PORT || 1337);

// Load .env
if (process.env.NODE_ENV !== 'production') {
require('dotenv').load();
PORT = (process.env.PORT || 1337);
const fs = require('fs');
const privateKey = fs.readFileSync('sslcert/key.pem', 'utf8');
const certificate = fs.readFileSync('sslcert/cert.pem', 'utf8');
const https = require('https');
const creds = { key: privateKey, cert: certificate };
https.createServer(creds, app).listen(PORT);

}

// grab heroku config vars
Expand All @@ -20,6 +32,11 @@ const SP_CLIENT_ID = process.env.SP_CLIENT_ID;
const SP_CLIENT_SECRET = process.env.SP_CLIENT_SECRET;
const SP_REDIRECT_URI = process.env.SP_REDIRECT_URI;

// LISTEN
// const listener = (process.env.PORT || 1337, () => {
// console.log('Webhook listening on port ' + listener.address().port);
// });

// GET

app.get('/', (req, res) => {
Expand Down Expand Up @@ -250,7 +267,3 @@ function authorizeSpotify(sender_psid, response) {
// }
// })
// }

const listener = app.listen(process.env.PORT || 1337, () => {
console.log('Webhook listening on port ' + listener.address().port);
});
Loading

0 comments on commit 1c6333c

Please sign in to comment.