Not CS, not software development, but it's a necessary byproduct of the two.
Just like when creating any sort of product, you have to find a way to get that product to end users
Depends on what you're trying to deploy
Code on your local machine You're saving it to some version control
What has to happen in order for your end users to interface with your code?
npm init -y
npm install --save express body-parser
touch server.js
const express = require('express')
const bodyParser = require('bodyparser')
const port = process.env.PORT || 3030
const server = express()
server.get('/', (req, res) => {
res.send(`Hellow world from ${port}`)
})
server.listen(port, err => {
if (err) console.log(err)
console.log(`Magic happening on ${port}`)
})
process.env.PORT
this says if there is no port I've given as a fallback port, if you can pull out an environment variable somewhere in my machine or assign one for me, use that port to hold up the server
can have multiple variables and processes
We are hosting and ngrok takes our local host and exposes it to the WWW. If my server goes down, it goes down as well.
If you don't know what port your web server is listening on, it's probably on port 80 for the default for HTTP.
ngrok http 3030
Gives us a HTTP port and a HTTPS port
Demo:
- Created public Github repo
- git clone
- npm init
- touch server.js
- npm install --save express body-parser
server.js
const express = require('express')
const bodyParser = require('bodyparser')
const corst = require('cors')
const port = process.env.PORT || 3030
const server = express()
server.use(bodyParser.json())
server.use(cors())
server.get('/', (req, res) => {
res.send(`Hellow world from ${port}`)
})
server.post('/payload, (req, res) => {
console.log(req.body)
res.send(req.body)
}
server.listen(port, err => {
if (err) console.log(err)
console.log(`Magic happening on ${port}`)
})
.gitignore
/node_modules
- git add .
- git commit -m "init"
- git push -u origin master
Webhooks
Creating webhooks
First thing you want to do is look at the payload URL
If you have ngroks set up, the URL from ngroks is the one you'll need.
Let me select the individual events
If you want to test, you can send a test request
Since Ryan subscribed to the webhook to hit the URL on this post route of payload, any time someone interfaces with one of these events, it will send a request to that route.
ngrok is hosting this URL, but they're propping up/ piggybacking off of your local machine's port and builds it as a live URL.
Forwarding http//9146070a.ngrok.io -> localhost:3030
What this line is saying is: Expose localhost:3030 to this internet URL
Proxy:
Authority to represent someone else
Where does this code currently live? Who is spinning up the code?
My code lives on my machine and my machine is spinning it on a local host and ngrok is exposing it to the world.
Webhooks exposes a couple of things:
They'll report it to the ngrok URL which is hosting and standing proxy for my local host.
The URL that you give to the Github webhook payload portion is the URL that needs to be live on the internet