Skip to content

Instantly share code, notes, and snippets.

@juanarbol
Created Jul 6, 2022
Embed
What would you like to do?
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