Skip to content

Instantly share code, notes, and snippets.

@codevenkat
Created January 17, 2018 11:27
Show Gist options
  • Save codevenkat/640ac3564dcca1782f84edd403a50a83 to your computer and use it in GitHub Desktop.
Save codevenkat/640ac3564dcca1782f84edd403a50a83 to your computer and use it in GitHub Desktop.
Example of having server in separate file express.js
//ES6(ES2015) used
const express = require('express')
const http = require('http')
const app = require('./server/app')
const port = process.env.PORT || 8080
const server = http.createServer(app)
server.listen(port, () => {
console.log(`App started. Listening on port:${port}`)
})
/*
http.createServer(app).listen(port, () => {
console.log(`App started. Listening on port:${port}`)
})
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment