Created
January 26, 2020 15:39
-
-
Save LautaroJayat/49571f252ae96f3cee1a4b1f509a470b to your computer and use it in GitHub Desktop.
Starting the server, Step 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First we require the http native module and we store it in a variable | |
const http = require('http'); | |
// Then we set a port based on the following condition: if the enviroment variable | |
// 'PORT' exists, then we use it. Else, we use 3000. | |
const PORT = process.env.PORT || 3000; | |
// Then we call the createServer() function to initialize our server | |
// And we store it in a cool variable. | |
const server = http.createServer( | |
// Note this function, this function will allow us to add routing, | |
// functionallities and other stuff to our ser | |
() => { | |
console.log('Im the function that holds a lot of your server functions') | |
// Then we call the listen() function to start listening on the Port that we have set | |
}).listen(PORT); | |
server.on('listening', () => { console.log('We are listening on', PORT) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment