Skip to content

Instantly share code, notes, and snippets.

@juanarbol
Created July 6, 2022 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanarbol/89f3ff3b68ce0653f25bf671d8eb38bd to your computer and use it in GitHub Desktop.
Save juanarbol/89f3ff3b68ce0653f25bf671d8eb38bd to your computer and use it in GitHub Desktop.
This are the three services mentioned in the DT definition for N|S
// console.js
const http = require('http')
const PORT = process.env.PORT || 3000
http.createServer((req, res) => {
if (req.url === '/auth') {
console.log('AUTH handler')
const googleAuthURL = 'http://localhost:4000'
const gReq = http.request(googleAuthURL)
gReq.end()
gReq.on('close', () => res.writeHead(200).end('Google made it'))
} else if (req.url === '/auth-2fa') {
const googleAuthURL = 'http://localhost:4000/2fa'
const twofaR = http.request(googleAuthURL)
twofaR.end()
twofaR.on('close', () => res.writeHead(200).end('Google made it with twilio'))
} else {
res.end('Love you <3')
}
}).listen(PORT)
// google-auth.js
const http = require('http')
const PORT = process.env.PORT || 4000
http.createServer((req, res) => {
if (req.url === '/2fa') {
const twilioURL = 'http://localhost:5000'
const twilioR = http.request(twilioURL)
res.writeHead(200).end('Google made it')
twilioR.end()
} else {
console.log('Google root handler')
res.writeHead(200).end('Love you <3')
}
}).listen(PORT)
// twilio.js
const http = require('http')
const PORT = process.env.PORT || 5000
http.createServer((req, res) => {
res.writeHead(200).end('From twilio <3')
}).listen(PORT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment