Last active
August 22, 2017 11:12
-
-
Save mirajehossain/f69a0de0e46a7d402b7c794b7f2a9bd1 to your computer and use it in GitHub Desktop.
This is for basic express server configuration for API
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
const express = require('require'); | |
const app = express(); | |
const bodyParser = require('body-parser'); | |
const morgan = require('morgan'); | |
const port = process.env.PORT || 8080; | |
app.use(bodyParser.urlencoded({extended:false})); | |
app.use(bodyParser.json()); | |
app.use(morgan('dev')); | |
app.get('/', function(req, res) { | |
res.send('Hello! The API is at http://localhost:' + port + '/api'); | |
}); | |
app.listen(port,function(){ | |
console.log('Server running at http://localhost:'+port); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment